Skip to content

Instantly share code, notes, and snippets.

James Cleveland radiosilence

Block or report user

Report or block radiosilence

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View immutable-vs-mutatable.rb
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
View .zpreztorc
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
View backup.yml
- message: test psot 8
id: '220955331788460_220956781788315'
comments:
data:
- message: test comment
id: '220958945121432'
paging:
cursors:
before: >-
WTI5dGJXVnVkRjlqZAFhKemIzSTZANakl3T1RVNE9UUTFNVEl4TkRNeU9qRTFNakl5TlRReE1qVT0ZD
View gist:962dda928a35616e514bd806098645be
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'))
}
@radiosilence
radiosilence / example.ts
Last active Apr 21, 2017
I am having a confuse about generics
View example.ts
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'
}
}
@radiosilence
radiosilence / utils.js
Created Nov 17, 2014
Handy function to turning a nested object into a list of string based constants.
View utils.js
"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;
View gist:b65b268e74b24f0ffc79
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 / index.html
Last active Aug 29, 2015
Versioned repository pattern for JS
View index.html
<!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 / comments.json
Created Jan 14, 2014
Shitty first attempt at something with React.
View comments.json
[{"author":"Barry Smith","text":"Test"},{"author":"James Brown","text":"ASDFG!"}]
View comments.json
[{"author":"Barry Smith","text":"Test"},{"author":"James Brown","text":"ASDFG!"}]
You can’t perform that action at this time.