Skip to content

Instantly share code, notes, and snippets.

@neuronix
neuronix / gist:2016071
Created March 11, 2012 11:20
Rendering dynamic parameters in a dust.js helper
// Handy function to render dynamic parameters in a dust.js helper
function renderParameter(name, chunk, context, bodies, params) {
if (params && params[name]) {
if (typeof params[name] === "function") {
var output = "";
chunk.tap(function (data) {
output += data;
return "";
}).render(params[name], context).untap();
return output;
@Fire-
Fire- / requestUpload.js
Last active July 12, 2017 10:20
example for uploading files to Hipchat with the v2 api with node.js and the Request package
var request = require('request'), //ezmode
fs = require('fs');
var uploadFileName = 'tit.jpg'; // this is a local file, but could be any file or data you want to read in
//ITS A BIRD I SWEAR
fs.readFile('./' + uploadFileName, function read(err, data) {
// hipchat appears to expect the file as a byte array
// and does not support Content-Transfer-Encoding at the time of this gist's creation
request.post({
@Kalgar
Kalgar / View Hierarchy - iOS
Created March 24, 2011 04:37
iOS function for dumping view hierarchy
***************************************************************************************************
DISCLAIMER:
I did not write this, I found it on Stack Overflow attributed to user Sophtware. Finding it useful, I decided to save this here, in case SO deleted the page (since the question was closed as a non-question)
***************************************************************************************************
void dumpViews(UIView* view, NSString *text, NSString *indent)
{
Class cl = [view class];
NSString *classDescription = [cl description];
@alexhajdu
alexhajdu / UIImageView+Rotate.h
Last active December 13, 2018 20:33
UPDATE: Added stop, pause and resume animation methods. UIImageView category - 360° rotating with duration and repeat count. USAGE: [_myImageView rotate360WithDuration:1.0 repeatCount:0]; //0 for infinite loop
//
// Created by Alex Hajdu on 5/27/13.
// Copyright (c) 2013 Mr.Fox and friends. All rights reserved.
//
// To change the template use AppCode | Preferences | File Templates.
//
#import <Foundation/Foundation.h>
@Inferis
Inferis / ViewController.swift
Last active December 1, 2019 23:27
Beginnings of a GCD wrapper in swift
import UIKit
import QuartzCore
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel
@IBOutlet weak var counter: UILabel
override func viewDidLoad() {
super.viewDidLoad()
@mnbayan
mnbayan / MKMapViewExtension.swift
Created February 23, 2015 02:33
MKMapView extension to center map to coordinates with defined zoom level using Swift language
//
// MKMapViewExtension.swift
// AutocompleteTextfieldSwift
//
// Created by Mylene Bayan on 2/22/15.
// Copyright (c) 2015 MaiLin. All rights reserved.
//
import Foundation
import MapKit
@bulwinkel
bulwinkel / mapToBundle.kt
Created January 7, 2017 13:35
Partial implementation of converting a `Map<String, V>` to a Bundle.
package com.bulwinkel.android
import android.os.Bundle
import android.os.IBinder
import android.os.Parcelable
import java.io.Serializable
fun <V> Map<String, V>.toBundle(bundle: Bundle = Bundle()): Bundle = bundle.apply {
forEach {
val k = it.key
@stigi
stigi / CocoaLumberjack.swift
Created August 16, 2014 21:41
A little hack to work comfortably with cocoa lumberjack in Swift.
// Created by Ullrich Schäfer on 16/08/14.
// Bitmasks are a bit tricky in swift
// See http://natecook.com/blog/2014/07/swift-options-bitmask-generator/
//enum LogFlag: Int32 {
// case Error = 0b1
// case Warn = 0b10
// case Info = 0b100
precedencegroup ForwardPipe {
associativity: left
}
infix operator |> : ForwardPipe
func |> <T, U>(value: T, function: ((T) -> U)) -> U {
return function(value)
}
@paulz
paulz / remove-boilerplate-comments-from-xcode-templates.sh
Created December 13, 2015 08:06
Remove Useless Header comments from Xcode Templates
#!/bin/bash
# Usage:
# $ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates
# $ bash ~/remove-boilerplate-comments-from-xcode-templates.sh
# Repeat for /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates
find -E . -type f \
\( -regex '.*\.[chm]' -or -regex '.*\.swift' \) \
-exec sed -i '' '1,/^$/d' '{}' ';'