Skip to content

Instantly share code, notes, and snippets.

@HyShai
HyShai / ProtocolReplacer
Last active August 29, 2015 13:56
protocol replacer bookmarklet that works in chrome (iOS) - useful for trying new openURL schemes
//have to wait for the keyboard for the url bar to leave before triggering the keyboard for the prompt, hence the timeout
javascript:setTimeout(function(){window.location=document.location.href.replace(document.location.protocol,prompt("Enter New Protocol: ("+document.location.protocol+")")+":")},1000)
#!/bin/bash
img=/Users/$USER/Downloads/tmp64.img
pbpaste 2>&1 | wget --quiet -i - -O $img&&
echo "<img src=\"data:image/png;base64,$(base64 $img)\" />" | pbcopy &&
rm $img
//PhotoIndex Route
export default Ember.Route.extend({
model:function() {
var store = this.get('store');
return store.find('photo', 1);
}
});
//PhotosAdapter
export default Ember.FixtureAdapter.extend();
//photo.hbs
/*snip*/
{{#each album in albums}}
{{#link-to 'albums.album' album}}
{{album.name}} //this loads properly
{{/link-to}}
{{/each}}
//routes/albums.js
model: function(params) {
@HyShai
HyShai / base64imgconv.py
Created July 27, 2014 14:44
base64imgconv.py
import base64
import requests
import clipboard
import webbrowser
from sys import argv
import urllib
img = requests.get(clipboard.get()).content
f=base64.b64encode(img)
html = '<img src="data:image/png;base64,{0}" />'.format(f)
clipboard.set(html)
@HyShai
HyShai / pushRemind.py
Created July 29, 2014 14:07
pushRemind.py
from sys import argv
import notification
#this will open the url right away without tapping on the notification
notification.schedule(argv[1],1,'',argv[2])
@HyShai
HyShai / url_lengthener.py
Last active August 29, 2015 14:04
url-lengthener.py
welcome_msg = '''url_lengthener is a poor man's CleanLinks.
See: https://itunes.apple.com/us/app/clean-links/id623671942?mt=8
It takes a shortened url and returns the lenthened url.
The inbound shortened url can either be provided as a command line
argument or on the iOS clipboard.
url_lengthener follows all header redirects, instead of downloading
the entire webpage as CleanLinks does,
(See: https://twitter.com/gcaprio/status/418040618636435456)
which 1) saves you bandwidth and 2) doesn't register as a click (at least for bit.ly)
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""Download Zip bundle of Python package requirements for MarkdownPDF.py
and extract them to 'site-packages' sub-directory.
This is meant for Pythonista (an iOS app) users as an easy way to install
these packages.
Packages included in the Zip bundle:

Keybase proof

I hereby claim:

  • I am hyshai on github.
  • I am hyshai (https://keybase.io/hyshai) on keybase.
  • I have a public key whose fingerprint is E04A 7157 776D B8E0 8D81 A5B5 C2B0 32C3 7FC2 5B81

To claim this, I am signing this object:

@HyShai
HyShai / cleanNuzzle.py
Last active August 29, 2015 14:05
cleanNuzzle.py
from bs4 import BeautifulSoup
import requests
import re
import clipboard
nuzzle = clipboard.get()
url = re.search("^http.+",nuzzle,re.MULTILINE)
url = url.group(0)
resp = requests.get(url)