Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
@icodeforlove
icodeforlove / dabblet.css
Created February 19, 2014 19:55
Untitled
body {
background: #222;
font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
}
.comment-box {
border: transparent 1px solid;
height: 90px;
position: relative;
}
@icodeforlove
icodeforlove / dabblet.css
Created February 28, 2014 21:55
Untitled
body {
padding: 0;
margin: 0;
}
.body {
opacity: .3;
position: absolute;
left: 0;
right: 0;
top: 0;
@icodeforlove
icodeforlove / GameViewController.swift
Created June 25, 2014 11:40
working version of GameViewController.swift for iOS 7.1
//
// GameViewController.swift
//
import UIKit
import SpriteKit
class GameViewController: UIViewController {
override func viewDidLoad() {
@icodeforlove
icodeforlove / CCTabeView.cpp
Created July 2, 2014 20:34
gives CCTableView the ability to dequeueCellWithTag, this is very useful when using multiple custom CCTableViewCell's and wanting to be able to reuse them.
CCTableViewCell *CCTableView::dequeueCellWithTag(int nTag)
{
CCTableViewCell *cell = NULL;
for (int i = 0, len = m_pCellsFreed->count(); i < len; i++) {
CCTableViewCell *tempCell = (CCTableViewCell*)m_pCellsFreed->objectAtIndex(i);
if (tempCell->getTag() == nTag) {
cell = tempCell;
cell->retain();
m_pCellsFreed->removeObjectAtIndex(i);
@icodeforlove
icodeforlove / prettyTime.cpp
Last active August 29, 2015 14:03
easy way to get pretty times in c++
const char * niceTime(time_t targetTime, time_t now = time(0)) {
const char *periods[8] = {"second", "minute", "hour", "day", "week", "month", "year", "decade"};
float lengths[7] = {60.0, 60.0, 24.0, 7.0, 4.35, 12.0, 10};
int difference = now > targetTime ? now - targetTime : targetTime - now;
int i = 0;
for (; difference >= lengths[i] && i < 7; i++) {
difference /= lengths[i];
}
<!-- react code -->
<script type="text/jsx">
/**
* @jsx React.DOM
*/
var Example = React.createClass({
style: `
view {
width: 100px;
height: 100px;
@icodeforlove
icodeforlove / GameControls.h
Created July 9, 2014 14:40
SpriteKit component
//
// GameControls.h
// Hiss
//
// Created by Chad Scira on 6/21/14.
// Copyright (c) 2014 Chad Scira. All rights reserved.
//
#import <SpriteKit/SpriteKit.h>
@icodeforlove
icodeforlove / rcs.settings.js
Created July 14, 2014 19:40
rcs settings example
function RCSPropertiesInit (Properties) {
Properties.setBaseUrl('/');
// defaulting number values to px values
Properties.registerProperty(/.*/, function (name, value) {
var stringValue = String(value),
numberPropertyKeys = /^(?:column-count|fill-opacity|flex|flex-grow|flex-shrink|font-weight|line-clamp|opacity|order|orphans|widows|z-index|zoom)$/,
numberValues = /^([a-z0-9.]+) ?(?:([a-z0-9.]+) ?)?(?:([a-z0-9.]+) ?)?(?:([a-z0-9.]+) ?)?$/;
if (name.match(numberPropertyKeys) || !numberValues.test(stringValue)) {
@icodeforlove
icodeforlove / hapi-routes.js
Created July 17, 2014 23:01
hapi-routes.js
// routes/products.js
module.exports = [
{
method: 'GET',
path: '/products',
config: {
validate: {
query: {
name: Joi.string().required(),
@icodeforlove
icodeforlove / react-with-addons-and-routes.js
Created July 20, 2014 13:47
react-with-addons-and-routes.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;