Skip to content

Instantly share code, notes, and snippets.

View radiosilence's full-sized avatar
🔥

James Cleveland radiosilence

🔥
View GitHub Profile
[{"author":"Barry Smith","text":"Test"},{"author":"James Brown","text":"ASDFG!"}]
@radiosilence
radiosilence / comments.json
Created January 14, 2014 17:04
Shitty first attempt at something with React.
[{"author":"Barry Smith","text":"Test"},{"author":"James Brown","text":"ASDFG!"}]
@radiosilence
radiosilence / index.html
Last active August 29, 2015 14:00
Versioned repository pattern for JS
<!doctype html>
<html>
<head>
</head>
<body>
<div id="main" />
<script src=http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js></script>
<script src=http://cdnjs.cloudflare.com/ajax/libs/react/0.10.0/JSXTransformer.js></script>
<script src=http://cdnjs.cloudflare.com/ajax/libs/react/0.10.0/react-with-addons.min.js></script>
<script type="text/jsx">
@radiosilence
radiosilence / gist:b65b268e74b24f0ffc79
Created September 18, 2014 11:56
fucking around with mori
Download the React DevTools for a better development experience: http://fb.me/react-devtools react.js:4356
DOM fully loaded and parsed uitest.html:40
You are using the in-browser JSX transformer. Be sure to precompile your JSX for production - http://facebook.github.io/react/docs/tooling-integration.html#jsx JSXTransformer.js:12703
_
function (obj) {
if (obj instanceof _) return obj;
if (!(this instanceof _)) return new _(obj);
this._wrapped = obj;
} underscore.js:36
mori
@radiosilence
radiosilence / utils.js
Created November 17, 2014 11:32
Handy function to turning a nested object into a list of string based constants.
"use strict";
module.exports = {
constantify: function constantify(app, obj, prevK) {
for (var k in obj) {
var nextK = prevK ? prevK + '.' + k : app + '.' + k;
if (obj[k] === null) obj[k] = nextK;
else constantify(app, obj[k], nextK);
}
return obj;
@radiosilence
radiosilence / example.ts
Last active April 21, 2017 13:09
I am having a confuse about generics
interface Z {
potato: string
}
abstract class A<T> { // I want to indicate that T will always at least implement Z
protected foo(bar: T) {
console.log(bar.potato); // ERROR: [ts] Property 'potato' does not exist on type 'T'
}
}
import * as moment from 'moment'
for (let i = 0; i < 12; i++) {
const start = moment('2018-02-28')
console.log(start.add(i * 30, 'd').format('DD MMMM YYYY'))
}
- message: test psot 8
id: '220955331788460_220956781788315'
comments:
data:
- message: test comment
id: '220958945121432'
paging:
cursors:
before: >-
WTI5dGJXVnVkRjlqZAFhKemIzSTZANakl3T1RVNE9UUTFNVEl4TkRNeU9qRTFNakl5TlRReE1qVT0ZD
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
#
# General
#
myArray = [{:key => nil, :x => nil}, {:z => nil}, {:potato => "hi", :deep => {:deep => {:deep => "asf" } } } ]
print myArray
print "\n"
potato = "hi"
# IMMUTABLE VERSION: make a new array but with hashes that are either the same exact hash or an updated version
myArray2 = myArray.map do |hash|
hash.key?(:key) ? hash.merge({:key => potato}) : hash
end