<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>tip &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/tip/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Sun, 02 Mar 2025 13:33:30 +0000</lastBuildDate>
	<language>en-GB</language>
	<copyright>© Terence Eden. 🄯 CC BY-SA. See https://shkspr.mobi/blog/copyright-and-copyleft/</copyright>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>tip &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Finding your most popular Tweets]]></title>
		<link>https://shkspr.mobi/blog/2020/05/finding-your-most-popular-tweets/</link>
					<comments>https://shkspr.mobi/blog/2020/05/finding-your-most-popular-tweets/#comments</comments>
				<dc:creator><![CDATA[Terence Eden]]></dc:creator>
		<pubDate>Wed, 13 May 2020 11:02:57 +0000</pubDate>
		<category><![CDATA[HowTo]]></category><category><![CDATA[tip]]></category><category><![CDATA[twitter]]></category>		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=34963</guid>

					<description><![CDATA[Twitter&#039;s search interface has all sorts of lovely and obscure options.  My three favourites are &#34;min_retweets:&#34;, &#34;min_replies:&#34;, and &#34;min_faves:&#34;  Using those filters, you can create a search for Tweets which meet a certain threshold. For example, here are my Tweets which have been liked more than 500 times:  twitter.com/search?q=from:edent min_faves:500  Here are the ones which have been…]]></description>
										<content:encoded>&lt;p&gt;Twitter's search interface has all sorts of &lt;a href="https://twitter.com/search-advanced"&gt;lovely and obscure options&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My three favourites are "min_retweets:", "min_replies:", and "min_faves:"&lt;/p&gt;

&lt;p&gt;Using those filters, you can create a search for Tweets which meet a certain threshold. For example, here are &lt;em&gt;my&lt;/em&gt; Tweets which have been liked more than 500 times:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/search?q=from%3Aedent%20min_faves%3A500&amp;amp;src=typed_query"&gt;&lt;code&gt;twitter.com/search?q=from:edent min_faves:500&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the ones which have been retweeted 300 times with at least 100 replies:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/search?q=from%3Aedent%20min_replies%3A100%20min_retweets%3A100&amp;amp;src=typed_query&amp;amp;f=live"&gt;&lt;code&gt;twitter.com/search?q=from%:edent min_replies:100 min_retweets:100&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, you don't have to do this for your own Tweets. You can perform the search on any term, or any user.&lt;/p&gt;
&lt;img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=34963&amp;amp;HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager"&gt;</content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2020/05/finding-your-most-popular-tweets/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Remove the first few lines from a string in PHP]]></title>
		<link>https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/</link>
					<comments>https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#comments</comments>
				<dc:creator><![CDATA[Terence Eden]]></dc:creator>
		<pubDate>Mon, 02 Mar 2020 08:31:07 +0000</pubDate>
		<category><![CDATA[HowTo]]></category><category><![CDATA[PHP]]></category><category><![CDATA[tip]]></category>		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=34332</guid>

					<description><![CDATA[Problem: I have a multiline string - not a file - and I want to remove the first few lines from it and keep the rest.  I found this surprisingly unintuitive. So these are notes in case I want to do it again. Feel free to suggest a better way!  Example  Given this input:  $str = &#34;Once upon\nA Time\nLived a big\nDragon\nCalled Cuthbert.&#34;;   I want the output to be:  &#34;Dragon\nCalled Cuthbert.&#34;  …]]></description>
										<content:encoded>&lt;p&gt;Problem: I have a multiline &lt;code&gt;string&lt;/code&gt; - not a file - and I want to remove the first few lines from it and keep the rest.  I found this surprisingly unintuitive. So these are notes in case I want to do it again. Feel free to suggest a better way!&lt;/p&gt;

&lt;h2 id="example"&gt;&lt;a href="https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#example"&gt;Example&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Given this input:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-php"&gt;$str = "Once upon\nA Time\nLived a big\nDragon\nCalled Cuthbert.";
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I want the output to be:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-php"&gt;"Dragon\nCalled Cuthbert."
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That is, remove the first &lt;em&gt;X&lt;/em&gt; lines in a string.&lt;/p&gt;

&lt;h2 id="exploding-kittens"&gt;&lt;a href="https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#exploding-kittens"&gt;Exploding kittens&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;Using &lt;a href="https://www.php.net/manual/en/function.explode.php"&gt;&lt;code&gt;explode()&lt;/code&gt;&lt;/a&gt; converts a &lt;code&gt;string&lt;/code&gt; into an &lt;code&gt;array&lt;/code&gt; based on a delimiter character.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;If &lt;code&gt;limit&lt;/code&gt; is set and positive, the returned &lt;code&gt;array&lt;/code&gt; will contain a maximum of &lt;code&gt;limit&lt;/code&gt; elements with the last element containing the rest of &lt;code&gt;string&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;This code removes the first &lt;strong&gt;three&lt;/strong&gt; lines and keeps the rest&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-php"&gt;$str = explode("\n", $str, 4)[3];
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here's a way to visualise what's going on:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-php"&gt;$str = "1\n2\n3\n4\n5\n6";
print_r(explode("\n", $str, 4));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Outputs:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-php"&gt;Array
(
    [0] =&amp;gt; 1
    [1] =&amp;gt; 2
    [2] =&amp;gt; 3
    [3] =&amp;gt; 4\n5\n6
)
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="what-not-to-do"&gt;&lt;a href="https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/#what-not-to-do"&gt;What not to do...&lt;/a&gt;&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Loop through the string, counting the instances of &lt;code&gt;\n&lt;/code&gt; and then substringing based on that position.&lt;/li&gt;
&lt;li&gt;Write the string to a file and then &lt;a href="https://www.php.net/manual/en/function.fgets.php"&gt;read it line by line&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=34332&amp;amp;HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager"&gt;</content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2020/03/remove-the-first-few-lines-from-a-string-in-php/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
