Skip to content

Instantly share code, notes, and snippets.

javascript:(function({
var INSTAPAPER=true,w=window,d=document,pageSelectedTxt=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pageTitle=d.title,pageUri=w.location.href,tmplt="";
tmplt="From ["+pageTitle+"]("+pageUri+"):\n\n";
if(pageSelectedTxt!="") {
pageSelectedTxt=">%20"+pageSelectedTxt;
pageSelectedTxt=pageSelectedTxt.replace(/(\r\n|\n+|\r)/gm,"\n");
pageSelectedTxt=pageSelectedTxt.replace(/\n/g,"\n>%20\n>%20");
w.location.href="nvalt://make/?txt="+encodeURIComponent(tmplt+pageSelectedTxt)+"&title="+encodeURIComponent(pageTitle)
}
else {
sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/elcapitaninstaller --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app –nointeraction
@hanvari
hanvari / mysql-disable-foreign-check.sql
Last active August 29, 2015 14:06
MySQL Disable foreign-key checks to truncate a table
SET FOREIGN_KEY_CHECKS=0;
truncate table schema.table ;
SET FOREIGN_KEY_CHECKS=1;
@hanvari
hanvari / PDO_Cheatsheet.php
Created August 25, 2014 22:11
PHP PDO Cheatsheet
<?php
/*
Reference:
http://code.tutsplus.com/tutorials/why-you-should-be-using-phps-pdo-for-database-access--net-12059
*/
function connect(){
/*
@hanvari
hanvari / serve_download.php
Created August 25, 2014 21:39
PHP Serve File for Download
<?php
function DownloadFile($file) {
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
# header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');