Skip to content

Instantly share code, notes, and snippets.

@AmrEldib
AmrEldib / EmbedYouTubeVideo.html
Last active December 27, 2015 08:38
Sample for Embed Code of a YouTube Video
<iframe width="640" height="360" src="//www.youtube.com/embed/XyLQjMC2Q38?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>
@AmrEldib
AmrEldib / PopupYouTubeVideo.js
Last active December 27, 2015 08:39
Bookmark to Open YouTube Video in Popup Window
javascript:(function()
{
var url = window.location;
if(url.origin.indexOf("www.youtube.com") == -1)
{
alert("Sorry, this is not a YouTube page! URL: " + url.href);
}
else
{
var width = "width=" + 600;
@AmrEldib
AmrEldib / ShareToTwitter.js
Last active December 27, 2015 08:39
Bookmark to Share to Twitter
javascript:(function(){window.twttr=window.twttr||{};var%20D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;if(C>A){G=Math.round((C/2)-(A/2))}window.twttr.shareWin=window.open('http://twitter.com/share','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');E=F.createElement('script');E.src='http://platform.twitter.com/bookmarklets/share.js?v=1';F.getElementsByTagName('head')[0].appendChild(E)}());
@AmrEldib
AmrEldib / ShareToFacebook.js
Last active December 27, 2015 08:39
Bookmark to Share to Facebook
javascript:var%20d=document,f='https://www.facebook.com/share',l=d.location,e=encodeURIComponent,p='.php?src=bm&v=4&i=1375780263&u='+e(l.href)+'&t='+e(d.title);1;try{if%20(!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z)%20{a=function()%20{if%20(!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if%20(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)
@AmrEldib
AmrEldib / ShareToAppNet.js
Last active December 27, 2015 08:39
Bookmark to Share to App.Net
javascript:(function(){window.open("https://alpha.app.net/intent/post?text="+encodeURIComponent(document.title+"%20%E2%80%93%20"+%20window.location))}());
@AmrEldib
AmrEldib / ShareToSpringpad.js
Last active December 27, 2015 08:39
Bookmark to Share to Springpad
javascript:(function(){SP_HOST='//springpad.com';try{var%20x=document.createElement('SCRIPT');x.type='text/javascript';x.src=SP_HOST+'/public/clipper.js?'+(new%20Date().getTime()/100000);document.getElementsByTagName('head')[0].appendChild(x);}catch(e){var%20u=SP_HOST+'/clip.action?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document&&document.title||'');try{window.open(u,'sp_popout','width=630,height=600');}catch(e){window.location=u;}}})();
@AmrEldib
AmrEldib / Sync_gh-pages_with_master.sh
Last active August 29, 2015 14:07
Easily keep gh-pages in sync with master
# go to the gh-pages branch
git checkout gh-pages
# bring gh-pages up to date with master
git rebase master
# commit the changes
git push origin gh-pages
# return to the master branch
git checkout master
# Source: http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/
@AmrEldib
AmrEldib / PushbulletBookmarklet.js
Last active August 29, 2015 14:07
Pushbullet Bookmarklet
javascript:void(window.open('http://pushbullet.com/push/link?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)))
// Source: http://pastebin.com/183UqMc1
@AmrEldib
AmrEldib / ConvertHtmlTableToJsonArray.js
Last active August 29, 2015 14:07
Convert HTML Table to JSON Array
// Make sure to rename the object fields
// Table's header gets ignored
var tbl = $('table#tableToConvert tr:has(td)').map(function(i, v) {
var $td = $('td', this)
return {
wkid: $td.eq(0).text(),
name: $td.eq(1).text()
}
}).get();
@AmrEldib
AmrEldib / splitJsonArrayToMultipleFiles.js
Created October 12, 2014 22:27
Split JSON Array to Multiple Files
// This script uses Node.js
// the 'arrayFile.json' is in the same folder as where you're running this command.
// This is not a script, but just the commands. Run from the shell.
// Sample item from the JSON file:
// { "id": "1" , "name": "one" }
// Files are saved under the folder 'itemsFolder', each item is saved in a JSON file name '<id>.json'.
var itemsArray = require('./arrayFile.json');
itemsArray.forEach( function (item) { item.writeFileSync('itemsFolder/' + item.id + '.json', JSON.stringify(item) ); } );