Skip to content

Instantly share code, notes, and snippets.

View anovsiradj's full-sized avatar

MDMCDC anovsiradj

View GitHub Profile
// Table.js is a small library for manipulating NxN arrays.
// It takes an NxN array and a list of type formatters by column headers so:
// var table = new Table([['one', 'two', 'three'], ["1","jeff larson","3px"]], {
// one : function(it) { return +it; },
// two : function(it) { return it.toUpperCase(); },
// three : function(it) { return +it.replace("px", ''); }
// });
//
var Table = function(data, types){
this.data = data;

I feel the need to have a little rant about MooTools and ES7 and the whole 'Array.contains' hoo-hah.

When MooTools came out in 2006, the most popular framework was Prototype. As the name suggests, it extended prototypes, as did MooTools. People still referred to making websites with JavaScript as 'DHTML', there was no trim method on strings, there wasn't even a forEach method on arrays. JavaScript was a crippled language. IE6 ruled the waves.

MooTools, Prototype, Dojo, Base2 - they made the language usable, even fun, to work with. By using an incredible feature of JavaScript, prototypical inheritance, we were able to add features to the language that made it palatable.

Be it simple methods like number.toInt, string.trim, array.forEach, or familiar programming constructs such as Class, MooTools and its ilk took JavaScript from something impossible to work with to something that you could properly use to build awesome sites, and even apps - Microsoft, IE and desktop ruled everything, and the concept of a 'we

@irazasyed
irazasyed / strpos_arr.php
Created July 12, 2013 17:21
PHP: Strpos Array, Find in array!
<?php
/* strpos that takes an array of values to match against a string note the stupid argument order (to match strpos) */
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}
@danielstreit
danielstreit / memoize.js
Created February 14, 2015 03:13
a standalone memoize function inspired by lodash
function memoize(func, resolver) {
var memoized = function() {
var cache = memoized.cache;
var key = resolver ?
resolver.apply(this, arguments) :
arguments[0];
if (cache.has(key)) {
return cache.get(key);
}
@bxt
bxt / php-doc.mkd
Created March 6, 2011 23:59
List of phpdoc-like projects for generating documentation from javadoc-annotated php files

Since there's a lots of phpdoc-like php documentors and the like projects on the webs, and they are all named similar if not equal, I wanted to write a little overview:

phpdoctor of 02/2011

Currently using this, namespace support plus UML stuff.

phpdoctor of 01/2011

Didn't test it, looks good.

@azyobuzin
azyobuzin / Dockerfile
Last active November 19, 2020 04:20
Wine 上で Mono を動かすやつ
FROM ubuntu:17.04
# apt-get update がクソ遅いので日本サーバーに変更
RUN sed -i 's|//archive\.ubuntu\.com|//jp\.archive\.ubuntu\.com|g' /etc/apt/sources.list
RUN dpkg --add-architecture i386 && \
apt-get update -y && \
apt-get install -y wget apt-transport-https software-properties-common && \
wget -O - https://dl.winehq.org/wine-builds/Release.key | apt-key add - && \
apt-add-repository -y https://dl.winehq.org/wine-builds/ubuntu/ && \
@zephyrfuzion
zephyrfuzion / Game.java
Created December 31, 2013 21:13
A simple number guessing game.
import java.util.Random;
import java.util.Scanner;
import java.lang.System;
/**
* Created with IntelliJ IDEA.
* User: fuzion
* Date: 12/26/13
* Time: 10:14 AM
@juliuscsurgo
juliuscsurgo / Bootstrap: no blue glow
Created January 3, 2013 01:29
Twitter Bootstrap: remove the blue glow in the form inputs
input[type="text"], textarea {
outline: none;
box-shadow:none !important;
border:1px solid #ccc !important;
}
@greypants
greypants / timeBasedAnimationPattern.js
Created September 17, 2012 18:48
JS: Time-based animation pattern
// Full Blog Post: http://viget.com/extend/time-based-animation
// requestAnimationFrame() polyfill: https://gist.github.com/1579671
window.APP = window.APP || {};
APP.pause = function() {
window.cancelAnimationFrame(APP.core.animationFrame);
};
APP.play = function() {
@rctay
rctay / gist:9829266
Created March 28, 2014 10:01
shuffle/randomize playlist/set tracks in Soundcloud Widget eg. https://w.soundcloud.com/player/?url=http://api.soundcloud.com/users/1539950/favorites
require(["lib/play-manager"], function(a) {
// via http://stackoverflow.com/a/6274381
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/shuffle [v1.0]
function shuf(o) { for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); }
shuf(a.source.models);
var c = a.getCurrentSound(), p = c ? c.isPaused() : false;
a.playNext(); a.playPrev(); // poor man's refresh of current playing song
if (p) a.pause(c); // preserve first-run state