Skip to content

Instantly share code, notes, and snippets.

@elhardoum
elhardoum / folder-live-sync.sh
Created January 19, 2020 13:51
Live sync of your local project with a remote using rsync and monitoring file changes
#!/usr/bin/env sh
function syncfunc(){
[ -f ./livesync.lock ] && exit -1
touch /tmp/livesync.lock
command -v say > /dev/null && say synchronizing || echo synchronizing
rsync -r -a -v -e "ssh -p22" --delete ./ user@host-or-ip:/path/to/remote/folder/eg/root/project1
command -v say > /dev/null && say synchronized || echo synchronized
rm -f /tmp/livesync.lock
}
@elhardoum
elhardoum / Icon.js
Created June 28, 2019 09:04
OpenWeatherMap SVG icons for React Native
import React from 'react'
import { G, Path } from 'react-native-svg'
import SvgIcon from 'react-native-svg-icon'
export const SvgIcons = {
wi01d: {
svg: <G><Path d="M22.749,35c-6.755,0-12.25-5.495-12.25-12.25s5.495-12.25,12.25-12.25 s12.25,5.495,12.25,12.25S29.504,35,22.749,35L22.749,35z M22.749,14.5c-4.549,0-8.25,3.701-8.25,8.25S18.2,31,22.749,31 s8.25-3.701,8.25-8.25S27.298,14.5,22.749,14.5L22.749,14.5z"/><Path d="M22.999,7c-0.829,0-1.5-0.672-1.5-1.5v-4c0-0.828,0.671-1.5,1.5-1.5 c0.828,0,1.5,0.672,1.5,1.5v4C24.499,6.328,23.827,7,22.999,7L22.999,7z"/><Path d="M14.342,9.186c-0.519,0-1.022-0.269-1.3-0.75l-2-3.463 c-0.415-0.717-0.169-1.635,0.549-2.049c0.717-0.415,1.635-0.169,2.049,0.549l2,3.463c0.415,0.717,0.169,1.635-0.549,2.049 C14.855,9.121,14.597,9.186,14.342,9.186L14.342,9.186z"/><Path d="M7.934,15.408c-0.254,0-0.512-0.064-0.749-0.201l-3.464-2 c-0.717-0.414-0.963-1.331-0.549-2.049s1.331-0.964,2.049-0.549l3.464,2c0.717,0.414,0.963,1.331,0.549,2.049 C8.957,15.14,8.453,15.408,7.934,15.408L7.934,15.408z
@elhardoum
elhardoum / chrome-extension-font-reset.css
Created January 25, 2019 10:18
Prevent Chrome from shrinking your extension pages by reducing font-size and forcing a specific font-family
body{font-family:inherit;font-size:initial}
@elhardoum
elhardoum / README.md
Last active June 11, 2019 17:22
Capture handles from Twitter

This is a workaround for Twitter search API being limited to only tweets from the past week.

Open Twitter on your favourite browser, open dev-tools, then go to console.

Make sure you are on Twitter search page, searching for your mentioned handle or hashtag or whatever.

Enter the code, it will only capture the handles but you can alter it to capture more data of your choosing.

It will attempt to adjust the page scroll to reach the bottom, in order to load more tweets, until you reach the end.

var start = +new Date, d, chrono
setInterval(function()
{
d = new Date( +new Date - start )
chrono = (''+d).match( /\d+:\d+(?= )/g )[0] + ':' + Math.floor(d.getMilliseconds()/100)
document.body.innerHTML = chrono.replace(/(\d+)/g, '<span>$1</span>').replace(':', '\'').replace(':', '"')
}, 100)
<?php
require __DIR__ . '/vendor/autoload.php';
use \DrewM\MailChimp\MailChimp;
$mc = new MailChimp('<your-mailchimp-api-key>');
// list ID
// When a user unsubscribes from the list, they cannot be subscribed again
// via the API, so use a unique list for this mailing purpose
@elhardoum
elhardoum / mc-feed.php
Created October 12, 2017 22:43
https://samelh.com/blog/?p=582 - Tweak MailChimp RSS Feeds to add the featured image, excerpt and a read more button.
<?php
/*
Plugin Name: Tweak MailChimp Feeds RSS
Plugin URI: https://samelh.com/blog
Description: Tweak MailChimp RSS Feeds to add the featured image, excerpt and a read more button.
Author: Samuel Elh
Version: 0.1
Author URI: https://go.samelh.com/buy-me-a-coffee
*/
import json
import urllib
downloader = urllib.URLopener()
# start by getting the full list of videos
with open('items.json') as json_data:
items = json.load(json_data)
# where to save the videos (directory)
save_to_dir = './'
<?php
use Predis\Client as PredisClient;
include __DIR__ . '/vendor/autoload.php';
function redis() {
global $Redis;
if ( !isset($Redis) || !$Redis instanceof PredisClient ) {