obj = (function() {
currentValue = 7
return {
valueOf: function() { return currentValue = currentValue+2 }
}
})()
(obj < 10) && (obj > 10) //true
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how I used to write sass! | |
// ----------------------- | |
// its short, sure, but short doesn't necessarily mean simple. Its very difficult for me | |
// to tell how a given element gets its styles -- element-1 is getting inherited styles | |
// from its container, and then has two different explicit selectors. At scale, | |
// its even harder to tell what overrides what, and file ordering begins to actually | |
// matter. Whenever I see code like this now, I refactor it asap -- before | |
// it gets too unwieldy and brittle to change. | |
.container-element | |
font: 15px verdana |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repository available at: https://github.com/raorao/ar-student-schema | |
For this challenge, I created a simple Students table using AR migration, populated a student object with basic methods and validations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As I've been know to yell, JavaScript is a stupid language, and I don’t mean that as an insult. | |
// For example, where Ruby has 50-ish enumerable methods to iterate over collections, | |
// JS has, basically, two. But that’s okay! That just means you have to build any complicated | |
// logical structures yourself in JavaScript, which makes your code more transparent and flexible. | |
// One important structure you often find yourself building from scratch is private functionality | |
// in object oriented programming. JavaScript closures are one way to achieve that goal. | |
var counter = (function() { | |
var currentCount = 0; | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<script src="jquery.js" type=text/javascript></script> | |
<script type=text/javascript> | |
$(document).ready(function() { | |
addKISSmetricsToButtons(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function slowApiLookup() { | |
try { | |
$url = "http://slowapi.com/delay/5.0"; | |
$curlSession = curl_init(); | |
curl_setopt($curlSession, CURLOPT_URL, $url); | |
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1); | |
curl_setopt($curlSession, CURLOPT_TIMEOUT,1); | |
$response = curl_exec($curlSession); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GroceryList.start | |
GroceryList.next | |
# nil | |
GroceryList.add("a gallon of milk") | |
# :ok | |
GroceryList.next | |
# "a gallon of milk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<style> | |
td { | |
border: 1px solid black; | |
width: 40px; | |
height: 40px; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RequestCache do | |
@moduledoc """ | |
Simple GenServer-based cache. | |
""" | |
use GenServer | |
@type t :: %{cache: %{optional(cache_key) => cache_value}, interval: integer} | |
@typep cache_key :: any | |
@typep cache_value :: any |