This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start ye'r engines | |
var | |
http = require('http'), | |
persist = require('pst-obj'), | |
state = { hits: 0 } | |
; | |
// api/layer to interface with state object | |
function getPageCount() { | |
state.hits++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$settings = array( | |
// one key is used for reading images (so that this can be public facing, but still prevent people from uploading) | |
'key_read' => '~', | |
// a separate secret key for storage. we don't want just any old monkey uploading images. | |
'key_store' => '123', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><html><head><title>JS1k Entry</title><meta charset="utf-8" /><style>html, body { margin: 0; padding: 0; border: 0; }#c { display: block; } /* kill scrollbars from hell */</style></head><body><canvas id="c"></canvas><script> | |
var a = document.getElementsByTagName('canvas')[0]; | |
var b = document.body; | |
var d = function(e){ return function(){ e.parentNode.removeChild(e); }; }(a); | |
// unprefix some popular vendor prefixed things (but stick to their original name) | |
var AudioContext = window.AudioContext || window.webkitAudioContext; | |
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(f){ setTimeout(f, 1000/30); }; | |
// fix bug in safari: http://qfox.nl/weblog/218 | |
document.body.clientWidth; | |
// auto resize (original) canvas. call `onresize(w,h) to limit the size of the canvas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for brevity, this sample has some properties missing :/ | |
"client": { | |
"field": { | |
"firstname": { "type": "string", "req": true, "min": 2, "max": 50, "regex": "text", "description": "First Name" }, | |
"lastname": { "type": "string", "req": true, "min": 2, "max": 50, "regex": "text", "description": "Last Name" }, | |
"email": { "type": "string", "req": true, "regex": "email" }, | |
"portfolio": { "type": "integer", "control": "input", "default": "", "req": false }, | |
"clientproduct": { "type": "rel-many", "description": "Products this client uses", "control": "checklist" }, | |
"clientstate": { "type": "integer", "req": false, "control": "select", "description": "State" } | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Location:', '' + window.location); | |
console.log('Number of links:', document.querySelectorAll('a').length); | |
console.log('Number of _blank links:', document.querySelectorAll('a[target="_blank"]').length); | |
console.log('% of _blank links:', ~~( document.querySelectorAll('a[target="_blank"]').length / document.querySelectorAll('a').length * 100 ) ); | |
// changed .log() to .dir() for twitter | |
/* Tested on 2014-04-14 | |
Location: https://www.google.co.za/ | |
Number of links: 45 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Location:', '' + window.location); | |
console.log('Number of links:', document.querySelectorAll('a').length); | |
console.log('Number of _blank links:', document.querySelectorAll('a[target="_blank"]').length); | |
console.log('% of _blank links:', ~~( document.querySelectorAll('a[target="_blank"]').length / document.querySelectorAll('a').length * 100 ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(['injectCSS'], function(injectCSS) { | |
injectCSS(function(){/* | |
.case1 { | |
border: 3px solid #0f0; | |
} | |
*/}); | |
injectCSS('.case2 { border: 3px solid #00f; } '); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<script src="injectCSS.js"></script> | |
</head> | |
<body> | |
<div class="test case1">test case 1</div> | |
<div class="test case2">test case 2</div> | |
<script> | |
(function(){ | |
injectCSS(function(){/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Language=JScript %> | |
<!--#include file="json.asp" --><%/* https://raw.githubusercontent.com/douglascrockford/JSON-js/master/json2.js */%> | |
<% | |
var ftp = (function() { | |
/* | |
* Copy a file(s) to a directory on a remote FTP server. | |
* | |
* Adapted from the very usefull post @ http://benmeg.com/code/asp/ftp.asp.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"result": [ | |
"ftp> Local directory now C:\\some\\virtual\\folder.", | |
"ftp> lcd c:\\some\\folder\\and\\directory", | |
"Connected to some.site.com.", | |
"open some.site.com", | |
"220 Microsoft FTP Service", | |
"User (some.site.com:(none)): ", | |
"331 Password required for some_user.", | |
"", |
OlderNewer