Skip to content

Instantly share code, notes, and snippets.

View hswolff's full-sized avatar
🙃
😄

Harry Wolff hswolff

🙃
😄
View GitHub Profile
(function(log){
console.log = function(msg){
log.call(console, msg + "...Bitch!");
}
})(console.log)
@kreeger
kreeger / MarkdownOnCocoaTouch.md
Created October 25, 2012 16:32
Displaying Markdown on Cocoa Touch.

In writing my first iOS app, I found myself reaching out in a few areas of self-discovery regarding the Cocoa Touch framework and what it's capable of, especially in how it compares to Ruby and it's standard library (which is what I've been used to for the past few years of my life). I've grown to love Ruby mixins and monkey-patching, and was delighted to learn that Objective-C has something quite similar: categories. ClassName+CategoryName.{h,m} is all you need, and you can define new class/static and instance methods on an Objective-C class.

One of my other strong preferences is for the Markdown format, and thus I snagged one of the more popular C-based implementations of Markdown (named [Sundown][sun]) and wrote a category around UIWebView for effortlessly displaying a parsed file. This was all made possible in the first place by [an awesome post on Stack Overflow][sta] on using Sundown with Objective-C.

//
//  UIWebView+Markdown.h
//

#import <UIKit/UIKit.h>
@rix501
rix501 / dynamic-logs.coffee
Last active December 16, 2015 23:21
Because we needed a birdlog and a jvstinlog
# Description:
# Keep a variaty of logs
#
# Dependencies:
#
# Configuration:
#
# Commands:
# hubot logs - shows all logs stored
# hubot <name>log last <number> - show last number of logs
@capaj
capaj / component.js
Last active June 22, 2016 12:40
react stateful function component
import React from 'react'
import {observer} from 'mobx-react'
import {observable} from 'mobx'
const state = observable({
value: 0
})
const Comp = (props) => {
return <div onClick={() => state.value++}>click to increase counter value: {state.value}</div>
@taion
taion / async-props-style.js
Last active January 24, 2017 17:14
React Router data fetching
// Define your components like:
class MyComponent extends React.Component {
static fetchData = (params) => {
// return an action here.
};
/* ... */
}
function fetchComponentData(component, store, params) {
@duncanbeevers
duncanbeevers / sc-dl-min.js
Created March 22, 2012 12:16 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(window){var i,$sound,$buttonGroup;var $sounds=$(".sound");var clientId=require("config").get("client_id");var oauthToken=require("lib/connect").getAuthToken();var conversionHelper=require("lib/helpers/conversion-helper");var $downloadButton,size;var params,downloadUrl,onSuccess;for(i=$sounds.length-1;i>=0;i--){$sound=$($sounds[i]);var soundcloudUrl="https://soundcloud.com"+($sound.find(".soundTitle__title").attr("href")||window.location.pathname);params={url:soundcloudUrl,client_id:clientId};onSuccess=function($sound){return function(data){var params={client_id:clientId};downloadUrl=require("lib/url").stringify({query:params},data.stream_url+".mp3");$buttonGroup=$($sound.find(".sound__soundActions .sc-button-group")[0]);size=$buttonGroup.find(".sc-button:first")[0].className.match(/sc-button-((?:small)|(?:medium))/)[1];$downloadButton=$('<a class="sc-button sc-button-download sc-button-icon sc-button-responsive">Download</a>').attr({title:"Download this sound ("+conversionHelper.bytesToMB(data.origi
@developit
developit / async-examples.js
Last active February 19, 2020 00:43
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;
{
"exclamations": [
"Holy Agility",
"Holy Almost",
"Holy Alphabet",
"Holy Alps",
"Holy Alter Ego",
"Holy Anagram",
"Holy Apparition",
"Holy Armadillo",
@jpantuso
jpantuso / osx_lion_rail_setup.md
Created July 27, 2011 19:51
Setup OS X 10.7 w/ homebrew, oh-my-zsh, rvm, rails, and MySQL