Skip to content

Instantly share code, notes, and snippets.

@jrichardlai
jrichardlai / ErrorManager.java
Last active February 7, 2018 20:44
Bugsnag integration with React Native
import android.util.Base64;
import android.util.Log;
import com.bugsnag.android.Bugsnag;
import com.bugsnag.android.MetaData;
import com.bugsnag.android.Severity;
import com.facebook.react.bridge.*;
import java.io.File;
import java.io.InputStream;
//
// UIBarButtonItem+Badge.swift
// PiGuardMobile
//
// Created by Stefano Vettor on 12/04/16.
// Copyright © 2016 Stefano Vettor. All rights reserved.
//
import UIKit
@alskipp
alskipp / creditCardValidationA.swift
Last active April 30, 2016 14:12
Credit card validation in Swift for Swift London Meetup
// Swift 2.0
/* Function composition operator */
infix operator •> { associativity left precedence 150 }
func •> <A,B,C> (f:A -> B, g:B -> C ) -> A -> C {
return { g(f($0)) }
}
extension Array where T: IntegerType {
func sum() -> T {
@olistik
olistik / gist:4943295
Created February 13, 2013 09:25
Handle CORS with Rails
# application_controller.rb
before_filter :handle_cors
def handle_cors
if env.keys.include? "HTTP_ORIGIN"
response.headers['Access-Control-Allow-Origin'] = 'http://www.myapp.com'
end
end
@jfromaniello
jfromaniello / gist:4087861
Last active February 6, 2022 03:53
socket-io.client send the cookies!
/*
* Little example of how to use ```socket-io.client``` and ```request``` from node.js
* to authenticate thru http, and send the cookies during the socket.io handshake.
*/
var io = require('socket.io-client');
var request = require('request');
/*
* This is the jar (like a cookie container) we will use always
@baamenabar
baamenabar / getElementByClass.js
Created November 6, 2012 19:00
Dustin Diaz's get element by class JS function
/*
taken from http://www.dustindiaz.com/top-ten-javascript
*/
function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
@p5150j
p5150j / rubyvars
Created November 6, 2012 18:53
ruby puts vars
games = ["Super Mario Bros.", "Contra", "Metroid", "Mega Man 2"]
puts "Games in your vast collection: #{games.count}" unless games.empty?
@mluton
mluton / gist:4026691
Created November 6, 2012 18:52
Format Date in User's Preferred Short Format
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSLog(@"now: %@", [dateFormatter stringFromDate:[NSDate date]]);
@supersym
supersym / yesno.sh
Created November 6, 2012 18:42
Bash scripts
while true
do
echo -n "Please confirm (y or n) :"
read confirm
case $confirm in
y|Y|YES|yes|Yes)
break
;;
n|N|no|NO|No)
echo Aborting - you entered $confirm
@flavioespinoza
flavioespinoza / index.html
Created November 6, 2012 17:28 — forked from benjchristensen/index.html
Interactive Line Graph (D3)
<html>
<head>
<title>Interactive Line Graph</title>
<script src="http://d3js.org/d3.v2.js"></script>
<!--
using JQuery for element dimensions
This is a small aspect of this example so it can be removed fairly easily if needed.
-->
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="sample_data.js"></script>