Skip to content

Instantly share code, notes, and snippets.

View Neos21's full-sized avatar
:octocat:
https://neos21.net/

Neos21 Neos21

:octocat:
https://neos21.net/
View GitHub Profile
if (!Array.prototype.reduce)
{
Array.prototype.reduce = function(fun /*, initial*/)
{
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
// no value to return if no initial value and an empty array
if (len == 0 && arguments.length == 1)
@if(0)==(0) ECHO OFF
CScript.exe //NoLogo //E:JScript "%~f0" %*
GOTO :EOF
@end
// zip compress command in wsh.
// @see http://scripting.cocolog-nifty.com/blog/2008/06/zip_3cb0.html
// @see http://n-arai.cocolog-nifty.com/blog/2008/04/activeserverpag_d5bc.html
if (WScript.Arguments.Count() < 2) {
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@remy
remy / gist:333954
Created March 16, 2010 13:21 — forked from madrobby/gist:333764
Beautiful one line array shuffle
// pure JS
function shuffle(array) {
return array.sort(function(){
return .5 - Math.random();
});
}
// with Prototype.js you can do
function shuffle(array){
return array.sortBy(Math.random);
/*
* 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();
// java.util.List の初期化を一行で書く
List<String> list = new ArrayList<String>() {{add("a"); add("b"); add("c");}};
// 変更不可能な List で良い場合は
List list = Arrays.asList("a", "b", "c");
// Arrays.asList をジェネリックスを使って書くと
List<Integer> list = Arrays.<Integer>asList(1, 2, 3);
// asList を使いつつ、追加可能な List を作るには、冗長だが以下のようにする
List<Integer> list = new ArrayList<Integer>(Arrays.<Integer>asList(1, 2, 3));
@unruthless
unruthless / CSS for <sup> and <sub>
Created May 26, 2010 01:31
CSS for <sub> and <sup>
sub, sup {
/* Specified in % so that the sup/sup is the
right size relative to the surrounding text */
font-size: 75%;
/* Zero out the line-height so that it doesn't
interfere with the positioning that follows */
line-height: 0;
/* Where the magic happens: makes all browsers position
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
if [ `echo 'hogefuga' | grep 'fuga'` ] ; then
echo 'ok'
fi
// ==UserScript==
// @name play on tumblr
// @namespace tag:[email protected],2008-04-03:/coderepos.org
// @description play current image or video on tumblr dashboard with 'ENTER' key. open notes with 'h' key. like it with 'l' key. if won't work, pray on tumblr!
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/show/*
// @include http://www.tumblr.com/tumblelog/*
// ==/UserScript==
//if (typeof window.Minibuffer != 'undefined') with (window.Minibuffer) {