Skip to content

Instantly share code, notes, and snippets.

View nelsonic's full-sized avatar
💭
Let's Build a Better World Together!☀️

Nelson nelsonic

💭
Let's Build a Better World Together!☀️
View GitHub Profile
@nelsonic
nelsonic / css-toggle
Created February 3, 2014 15:41
CSS ONLY Toggle Button with Valid HTML
<div>
<input type="checkbox" id="switch1" name="switch1" class="switch" />
<label for="switch1">First switch</label>
</div>
<style> /* put this in buttons.scss */
input.switch:empty
{
margin-left: -999px;

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@nelsonic
nelsonic / redis-server.conf
Last active August 29, 2015 14:27 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu
# https://gist.github.com/bdotdub/714533
description "redis server"
start on runlevel [23]
stop on shutdown
exec sudo -u redis /usr/bin/redis-server /etc/redis/redis.conf
respawn
@nelsonic
nelsonic / change_rspec.rb
Last active December 11, 2015 08:08
Coin Change Problem Solved in 5 Lines of Ruby. ( Method code on SINGLE Line! ;-) Do NOT do this in RL kids! ( Seriously Unreadable/Unmaintainable! Simply a Thought Exercise in taking compression to its logical conclusions ... ) Surprisingly fast to execute! :-P
class Change
def change(amount)
available_coins, coins, remaining_amount = [100,50,25,10,5,1], [], amount; available_coins.each { |coin| if ((remaining_amount/coin).to_int > 0) then (remaining_amount/coin).to_int.times { coins << coin }; remaining_amount = amount-coins.inject(:+) end }; return coins
end
end
describe Change do
it "returns [1] for 1" do
expect(subject.change(1)).to eq [1]
end
@nelsonic
nelsonic / disco.html
Last active December 14, 2015 06:29
Disco Squares CoffeeScript HTML5 Canvas Just copy paste the script into an .html file and see. A variation on the disco on p.21 of Jump Start CoffeeScript by Earle Castledine
<html>
<head>
<title> Disco Squares</title>
</head>
<body>
<style type="text/css">
html, body, #game {
width: 100%;
height: 100%;
margin: 1px;
@nelsonic
nelsonic / example-app.json
Last active December 16, 2015 02:39
example-app.json
{
 "attributes" : {
   "type" : "Application__c",
   "url" : "/services/data/v27.0/sobjects/Application__c/a07b0000004bXrFAAU"
 },
 "Mandatory__c" : false,
 "LastModifiedById" : "005b0000000MGa7AAG",
 "Featured_End_Date__c" : "2013-04-26T16:16:00.000+0000",
 "OwnerId" : "005b0000000MGa7AAG",
 "LastModifiedDate" : "2013-04-11T14:43:15.000+0000",
@nelsonic
nelsonic / HTTPHelper.java
Created April 18, 2013 03:43
This is what Nimil had.
/**
* @author Nimil Christopher
* @date 12 April 2013
* @description This class has the Rest Callouts to publish an application to
* the CDN
*/
public with sharing class HTTPHelper {
public static Http http;
@nelsonic
nelsonic / hello.coffee
Created April 19, 2013 13:59
A Basic Hello World NodeJS script in CoffeeScript. This can be a two or three line script. but i've done it this way to explain the components.
http = require 'http' # Require the HTTP Core NodeJS Module (notice the lack of brackets)
port = process.env.PORT or 4000 # The TCP port you want to "listen" on (see line #6) allows the system (e.g. Heroku to set it or uses 4000 on local machine)
http.createServer (req, res) -> # Creates a basic Web Server and gives you the REQuest and RESponse objects to the function
res.writeHead 200 # Write the HTTP Status Code "200" ("All OK") in the RESponse to the client (browser)
res.end 'Hello World!' # End the RESponse with the message 'Hello World'
.listen port # the dot before the word listen means "Chain" to the createServer and listen on the port
console.log "Visit: http://localhost:#{port}" # console.log allows you to write a "Note-to-self" on the command line.
### if any of the above is unclear, Google it! (or msg me for a personal Tutorial: https://twitter.com/nelsonic) ###
<apex:page standardController="Opportunity" extensions="jquery_minihack">
<style>
#myTitle {
font-size:20px;
text-align: center;
}
.element {
width:50%;
/**
* Copyright 2012 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software