Skip to content

Instantly share code, notes, and snippets.

View igstan's full-sized avatar

Ionuț G. Stan igstan

View GitHub Profile
/**
* @see http://www.mozilla.org/rhino/
* @see http://www.dabeaz.com/coroutines/
* @see http://www.python.org/dev/peps/pep-0342/
*
* @author Ionut G. Stan <ionut.g.stan ~ gmail.com>
* @license New BSD license
*/
var coroutine = function (f) {
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Coroutines</title>
<script type="application/javascript;version=1.8">
/**
* @see http://www.mozilla.org/rhino/
* @see http://www.dabeaz.com/coroutines/
* @see http://www.python.org/dev/peps/pep-0342/
DELIMITER $$
CREATE PROCEDURE `report`()
BEGIN
DECLARE col_number INT(2) DEFAULT 0;
DECLARE counter INT(2) DEFAULT 0;
DECLARE done INT(1) DEFAULT 0;
DECLARE last_prod VARCHAR(128) DEFAULT "";
DECLARE prod_name VARCHAR(128);
DECLARE cross_prod_name VARCHAR(128);
;PSPad user HighLighter definition file
[Settings]
Name=JavaScript 1.8
HTMLGroup=0
Label=1
FileType=*.js
CommentString=
SlashComment=1
CComment=1
SlashComment=1
-- Copyright (c) 2009, Ionut Gabriel Stan. All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without modification,
-- are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
/**
* Call constructor with a variable number of arguments.
*/
var Ctor = function (a, b) {
if (arguments.length === 0) {
return;
}
this.a = a;
module CNP (validCnp) where
validCnp :: String -> Bool
validCnp (x:xs) = validGenderDigit x && validBirthDate x (take 6 xs) && validControlDigit (x:xs)
validGenderDigit :: Char -> Bool
validGenderDigit x | x `elem` "123456" = True
| otherwise = False
validBirthDate :: Char -> String -> Bool
# Always load the Range addon
Range
# Source: http://ozone.wordpress.com/2006/03/15/blame-it-on-io/
Object unless := method(condition,
if(condition not, call evalArgAt(1), call evalArgAt(2))
)
Object slotsLike := method(slotName,
self slotNames select(containsAnyCaseSeq(slotName))
-- Strongly inspired from here: http://www.experts-exchange.com/Database/Miscellaneous/Q_24608444.html
SELECT
COUNT(*) AS total,
CASE
WHEN age >= 35 THEN 35
WHEN age >= 30 THEN 30
WHEN age >= 25 THEN 25
WHEN age >= 20 THEN 20
ELSE 0
END as age_interval
/**
* DERIVING THE Y COMBINATOR IN 7 EASY STEPS
*
* Ionut G. Stan | ionut.g.stan@gmail.com | http://igstan.ro | http://twitter.com/igstan
*
*
* The Y combinator is a method of implementing recursion in a programming
* language that does not support it natively (actually, it's used more for
* exercising programming brains). The requirement is the language to support
* anonymous functions.