Skip to content

Instantly share code, notes, and snippets.

View japboy's full-sized avatar
🏠
WFH

Yu Inao japboy

🏠
WFH
View GitHub Profile
@os0x
os0x / dollarX.js
Created July 30, 2008 07:12 — forked from cho45/dollarX.js
simple $X
// simple version of $X
// $X(exp);
// $X(exp, context);
// @source https:/raw.github.com/gist/3242
function $X (exp, context) {
context || (context = document);
var expr = (context.ownerDocument || context).createExpression(exp, function (prefix) {
return document.createNSResolver(context.documentElement || context).lookupNamespaceURI(prefix) ||
context.namespaceURI || document.documentElement.namespaceURI || "";
});
(let ((default-directory (expand-file-name "~/Dropbox/home/.emacs.d")))
(add-to-list 'load-path default-directory)
(load (expand-file-name "~/Dropbox/home/.emacs.d/subdirs.el") t t t))
(if (file-exists-p (locate-library "init"))
(load (locate-library "init") nil t nil))
@mathiasbynens
mathiasbynens / jquery.preload.js
Created April 22, 2010 17:11
JavaScript preload() function
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
var Q = require("q");
var HTTP = require("q-http");
function httpReadRetry(url, timeout, times) {
return HTTP.read(url)
.then(function (content) {
return content;
}, function (error) {
if (times == 0)
throw new Error("Can't read " + JSON.stringify(url));
@mattmccray
mattmccray / backbone_helper.coffee
Created October 14, 2010 08:44
Use Backbone.js classes as native CoffeeScript classes
# Backbone CoffeeScript Helpers by M@ McCray.
# Source: http://gist.github.com/625893
#
# Use Backbone classes as native CoffeeScript classes:
#
# class TaskController extends Events
#
# class TaskView extends View
# tagName: 'li'
# @SRC: '<div class="icon">!</div><div class="name"><%= name %></div>'
@ryanflorence
ryanflorence / static_server.js
Last active April 26, 2024 16:18
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@nissuk
nissuk / gist:813066
Created February 6, 2011 03:06
CakePHP(1.3)でJSON出力する単純な例
<?php // {app}/config/routes.php
/**
* Routes Configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different urls to chosen controllers and their actions (functions).
*
* PHP versions 4 and 5
*
@mkitt
mkitt / notes.md
Created February 13, 2011 03:24
AppleScript for use with Automator which allows opening files within Terminal Vim

What It Does

This AppleScript used in conjunction with Automator will allow you to set preferences for opening files via mouse click in the Terminal version of Vim. It will also allow you to fire up the Terminal version of Vim through Spotlight within the home directory.

Installation Notes

  • Fire up Automator
  • Choose "Application" from the workflow templates
  • Under the "Actions" panel select "Utilities"
  • To the right of "Utilities" drag an instance of "Run AppleScript" to the editor window
@bentruyman
bentruyman / express-stylus.html
Created February 13, 2011 19:27
Using Stylus Middleware with Express
<!doctype html>
<html lang="en">
<head>
<title>My Web Page</title>
<meta charset="utf-8">
<link href="/stylesheets/main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);