Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View 9kopb's full-sized avatar
💎
xyu.foundation

9kopb 9kopb

💎
xyu.foundation
View GitHub Profile
/*
* Bookmarklet for viewing source in iPad Safari
*/
javascript:(function(){
var w = window.open('about:blank'),
s = w.document;
s.write('<!DOCTYPE html><html><head><title>Source of ' + location.href + '</title><meta name="viewport" content="width=device-width" /></head><body></body></html>');
s.close();
@tbeseda
tbeseda / Snoopy
Created September 13, 2010 18:30
javascript:(function()%7Bvar%20d%3Ddocument%2Cs%2Ce%3Bvar%20el%3Dd.getElementById('snpy')%3Bif(typeof%20Snoopy!%3D'undefined')%7BSnoopy.toggle()%3Breturn%7Delse%20if(el)%7Bel.className%3D%2Fclosed%2F.test(el.className)%3Fel.className.replace('closed'%2C'')%3Ael.className%2B'%20closed'%3Breturn%7Ds%3Dd.createElement('link')%3Bs.setAttribute('href'%2C'http%3A%2F%2Fsnoopy-assets.allmarkedup.com%2Fsnoopy-min.css')%3Bs.setAttribute('rel'%2C'stylesheet')%3Bs.setAttribute('type'%2C'text%2Fcss')%3Bd.getElementsByTagName('head')%5B0%5D.appendChild(s)%3Be%3Dd.createElement('script')%3Be.setAttribute('src'%2C'http%3A%2F%2Fsnoopy-assets.allmarkedup.com%2Fsnoopy-min.js')%3Bd.getElementsByTagName('body')%5B0%5D.appendChild(e)%7D)()%3B
(function(window, undefined) {
var document = window.document, $ = window.jQuery;
var iframe = function(element) {
console.log('make jquery iframe element');
var iframe = $('<iframe frameborder=1 style="border: solid 1px #f00;" width="800" height="400"></iframe>');
console.log('append iframe to body');
$(element).after(iframe);
//$(element).hide();
// $("body").append(iframe);
@teeler
teeler / textify.js
Created May 24, 2011 20:43
Textify
// via http://textify.it/
/**
* @author Hakim El Hattab
*
* Recreates bitmap images using HTML text. Images are
* drawn onto a canvas element so that the pixels can
* be read. Letters, with colors matching the image pixels,
* are then placed at random locations on the screen.
*/
@alright
alright / gist:1107183
Last active September 26, 2015 13:57
Intuitive sorting of arrays in PHP
<?php
// Predefined constants
define('DO_SORT_BY_VALUE', 1);
define('DO_SORT_BY_KEY', 2);
define('DO_SORT_ASC', 1);
define('DO_SORT_DESC', 2);
define('DO_SORT_NATURAL', 3);
define('DO_SORT_NATURAL_CASE', 4);
define('DO_SORT_RANDOM', 5);
@cdown
cdown / gist:1163649
Last active April 9, 2024 01:10
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@takumakei
takumakei / qrcode.js
Created October 6, 2011 09:39
qrcode.js for the bookmarklet
// bookmarklet: qrcode
//
// javascript:void((function(d){var s=BOOKMARKLETSCRIPT=d.createElement('script');s.type='text/javascript';s.src='https://raw.github.com/gist/1266971/b5e0748c51dd0ffdf4a1abb00d14409a8220b7c2/qrcode.js';d.getElementsByTagName('head')[0].appendChild(s);})(document));
//
try {
(function(d){
var body = d.getElementsByTagName('body')[0];
var add = function(args) {
var target = args.target || body;
var elem = d.createElement(args.tag || 'div');
@padenot
padenot / stream.js
Created October 29, 2011 16:33
How to serve media on node.js
var http = require('http');
var path = require('path');
var fs = require('fs');
var AUDIOFILE = "./audio.ogg";
function serveWithRanges(request, response, content) {
var range = request.headers.range;
var total = content.length;
var parts = range.replace(/bytes=/, "").split("-");
@aemkei
aemkei / LICENSE.txt
Last active April 12, 2024 21:27 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Responsive Design Testing</title>
<style>
body { margin: 20px; font-family: sans-serif; overflow-x: scroll; }
.wrapper { width: 6000px; }
.frame { float: left; }
h2 { margin: 0 0 5px 0; }