Skip to content

Instantly share code, notes, and snippets.

@git2358
git2358 / gist:eb0b74ed888bb5e8ad17698b81448971
Created October 26, 2018 09:06 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@git2358
git2358 / appify
Created October 28, 2018 13:27 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@git2358
git2358 / bookmarklet-syntax.js
Created October 30, 2018 10:30 — forked from illusionfield/bookmarklet-syntax.js
Translate Bookmarklets
/**
* Web browsers use URIs for the href attribute of the <a> tag and for bookmarks. The URI scheme, such as http:, file:, or ftp:, specifies the protocol and the format for the rest of the string.
* Browsers also implement a prefix javascript: that to a parser is just like any other URI.
* Internally, the browser sees that the specified protocol is javascript, treats the rest of the string as a JavaScript application which is then executed, and uses the resulting string as the new page.
*
* The executing script has access to the current page, which it may inspect and change.
* If the script returns an undefined type (rather than, for example, a string), the browser will not load a new page, with the result that the script simply runs against the current page content.
* This permits changes such as in-place font size and color changes without a page reload.
*/
// Step 1: Get an API key here: https://developers.google.com/url-shortener/v1/getting_started#APIKey
// Step 2: Paste your api key below
// Step 3: Add the code below to your browser as a bookmark
// Step 4: Visit a non-goo.gl URL and click your bookmark
// NOTE: The security policy of some sites (such as this gist.github.com!) will prevent this from working.
// Check your javascript console if something doesn't work.
javascript:(function(){
var googleApiKey = 'INSERT YOUR API KEY HERE';
@git2358
git2358 / bookmarklet.url
Last active November 1, 2018 05:51 — forked from sv-in/bookmarklet.url
JS: Bookmarklet for displaying QR code of current URL (good for presentations)
javascript:void !function(max,sizes,index,image,size,style){while(index--&&(size=sizes[index])>max);style=image.style,style.position="fixed",style.zIndex=-1>>>1,style.top=style.left="50%",style.marginTop=style.marginLeft=size/-2+"px",style.imageRendering="pixelated",style.mixBlendMode="overlay",image.setAttribute("id","imageQR"),image.setAttribute("onclick","returnfalse;"),image.setAttribute("onmousedown","imageQR.remove()"),image.src="https://chart.apis.google.com/chart?cht=qr&chld=H|0&chs="+size+"x"+size+"&chl="+escape(location)}(Math.min(top.innerHeight,top.innerWidth),[100,150,200,250,300,350,400,500],8,document.body.appendChild(new Image))
@git2358
git2358 / gist:33766c2da6b54b43410f0986474b21a3
Created November 11, 2018 10:10 — forked from rmondello/gist:b933231b1fcc83a7db0b
Exporting (iCloud) Keychain and Safari credentials to a CSV file

Exporting (iCloud) Keychain and Safari credentials to a CSV file

After my dad died, I wanted to be able to have access any of his online accounts going forward. My dad was a Safari user and used iCloud Keychain to sync his credentials across his devices. I don’t want to have to keep an OS X user account around just to access his accounts, so I wanted to export his credentials to a portable file.

This is the process I used to create a CSV file of his credentials in the format “example.com,user,pass”. This portable format would be pretty easy to import into 1Password or Safari in the future.

The way I went about this isn’t great; it opens up more opportunities for apps to control one’s Mac through Accessibility APIs, it writes plaintext passwords to disk, and it could use some cleaning up. A better approach might leverage the security command line tool that ships with OS X. That said, I found this method to be a fun illustration of what’s possible us

@git2358
git2358 / gist:ebbecc2ce76c8ff9f16f07c8a29166f7
Created February 1, 2019 01:11 — forked from a-laughlin/gist:1035d616c666271e1fe3
Bookmarklet to quickly switch between a repo and the gh-pages (github.io) view.
// Instructions. Save as a bookmark. Click when on a repo or github.io (gh-pages branch) site.
javascript:(function(h,p){
location = /io$/.test(h) ?
'https://github.com/' + h.split('.')[0] + p:
'http://'+ p.split('/')[1]+'.github.io'+ '/' + p.split('/').slice(2).join('/')
})(location.host,location.pathname);
@git2358
git2358 / gist:9c58cad3362a26ea9ac139a4bcf0e654
Last active March 13, 2019 23:05 — forked from karlgroves/gist:7544592
Get DOM path of an element
function getDomPath(el) {
var stack = [];
while ( el.parentNode != null ) {
console.log(el.nodeName);
var sibCount = 0;
var sibIndex = 0;
for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {
var sib = el.parentNode.childNodes[i];
if ( sib.nodeName == el.nodeName ) {
if ( sib === el ) {
@git2358
git2358 / Auto-refresh bookmarklet
Created March 28, 2019 23:19 — forked from eculver/Auto-refresh bookmarklet
Auto-refresh bookmarklet
// origin: http://www.google.com/support/forum/p/Chrome/thread?tid=1a37ccbdde5902fd&hl=en
javascript:
timeout=prompt("Set timeout [s]");
current=location.href;
if(timeout>0)
setTimeout('reload()',1000*timeout);
else
location.replace(current);
function reload(){
@git2358
git2358 / mailTo.js
Created April 9, 2019 02:29 — forked from nrn/mailTo.js
Bookmarklet to mail a link/selected text
javascript:(function () {
var selected = getSelection().toString();
if (selected !== "") selected = '"...\n'+selected+'\n..."\n';
location.href = 'mailto:?SUBJECT='+encodeURIComponent(document.title)+'&BODY='+encodeURIComponent('\n'+location.href+'\n'+selected);
})()