Skip to content

Instantly share code, notes, and snippets.

View BlessYAHU's full-sized avatar
💻

A'braham Barakhyahu BlessYAHU

💻
View GitHub Profile
@BlessYAHU
BlessYAHU / exercise 2 - redux
Created October 19, 2010 18:01
Exercise 2
var countdown = (function() {
var index;
function log(){
console.log(index);
}
function iterate(){
log();
if(index>1) setTimeout(iterate, 1000);
@BlessYAHU
BlessYAHU / gist:636700
Created October 20, 2010 15:58
03-Skinning_cats
// Implement a number Prototype function for repeating strings.
// (4).times('test') --> 'testtesttesttest'
// Example in functional programming:
function repeatString(string, times){
var result = '';
while(times--) result += string;
return result;
}
@BlessYAHU
BlessYAHU / gist:636701
Created October 20, 2010 15:59
functional_vs_OO
// Exercise 1 - OO || !OO
// Define a data structure for cars (make and color), and a function
// that logs a string like "I'm a red Mercedes" to the console.
// Make two versions: a functional version, and a object-oriented version.
function logCar(params) {
if(params && params.color && params.make) {
console.log("I'm a " + params.color + " " + params.make );
}
}
@BlessYAHU
BlessYAHU / gist:636915
Created October 20, 2010 17:41
dom_events
<div id="the_div">
<ul id="the_list">
<li id="the_item">Click me!</li>
</ul>
</div>
<p id="log"></p>
<script type="text/javascript" charset="utf-8">
function log(string){
@BlessYAHU
BlessYAHU / DataController.cs
Created September 19, 2012 16:20
East Orientation in an MVC Action Result
public class DataController : Controller
{
public ActionResult Submit(string status)
{
var resultObject = new SomeViewModel();
_eastClass.PutStatus(status, fillResultObjectAction(resultObject);
return View(resultObject);
@BlessYAHU
BlessYAHU / index.html
Created September 24, 2012 19:20
[UPDATED!] showing another usage of input:checkbox. for full view: http://codepen.io/ImBobby/full/EdALB inspired from : http://designshack.net/design/notepad-to-do-list-psd
<div class="wrap">
<div class="header"><span>Todo List</span></div>
<div class="wrap-list">
<ol class="list">
<li>
<input type="checkbox" id="check-1" checked="checked">
<label for="check-1">Shop</label>
</li>
<li>
<input type="checkbox" id="check-2">
@BlessYAHU
BlessYAHU / gist:6644051
Last active December 23, 2015 13:39
Code has been changed to pseudocode, but intent is still there. Original code is using Underscore, fmap from drboolean's typeclasses library and autocurry from wu.js. Original code gets a list of filter commands and a list of products. Filter views are rendered only if products have properties matching filtercommand field names.
var lookupExecute = function( products, processCommands) {
this.commandArray = processCommands;
this.lookupArray = products;
};
// unwrapped values in functor, apply given function over each command object that has lookup items that meet the condition
lookupExecute.prototype.fmap = function(fn) {
var self = this,
mappedResults = map(this.commandArray, function(command) {
var matchedItems = self.lookupArray.filter(function(item) {
augmentProduct = function (findEmployee, carrierName, product) {
var view = this,
augmentedProduct = _.clone(product);
var augEmpRates = _.map(augmentedProduct.employeeRates, function (currRate) {
var augEmpRate = _.extend(currRate, { employee: {} });
return augEmpRate;
}
augmentedProduct.employeeRates = augEmpRates;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.83/Bacon.min.js"></script>
<style id="jsbin-css">
body {
font-size: 200px;
((global,Bacon)=> {
const pollingInterval = 1000;
const getCurrentDateAndTime = ()=> new Bacon.Next(new Date());
const getTime = (currentDate)=> ({
hour: currentDate.getHours ( ),
minutes: currentMinutes = currentDate.getMinutes ( ),
seconds: currentDate.getSeconds ( )
});
const convertMinutesAndSeconds = (currentTime)=> ({
hour : currentTime.hour,