Skip to content

Instantly share code, notes, and snippets.

@nielin
nielin / base64.js
Created June 10, 2018 17:23 — forked from jarus/base64.js
Base64 encode and decode in javascript
var Base64 = {
characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ,
encode: function( string )
{
var characters = Base64.characters;
var result = '';
var i = 0;
do {
@nielin
nielin / reflection.go
Created January 8, 2017 20:12 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@nielin
nielin / gist:9dc116ff4f12ef6b7248bf1e0a7ace06
Created August 28, 2016 01:01 — forked from Bouke/gist:10454272
Install FreeTDS, unixODBC and pyodbc on OS X

First, install the following libraries:

$ brew install unixodbc
$ brew install freetds --with-unixodbc

FreeTDS should already work now, without configuration:

$ tsql -S [IP or hostname] -U [username] -P [password]
locale is "en_US.UTF-8"

locale charset is "UTF-8"

@nielin
nielin / API.md
Created July 9, 2016 23:08 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@nielin
nielin / chat.js
Created May 7, 2016 02:24 — forked from mcvendrell/chat.js
Chat with Alloy models failing test
exports.definition = {
config: {
columns: {
"content": "String",
"date": "String",
"author": "String"
},
adapter: {
type: "properties",
collection_name: "chat"
@nielin
nielin / index.js
Created May 7, 2016 02:23 — forked from mcvendrell/index.js
Titanium: How to re-use the launch image in the app (TiDev.io): Alloy style
// Animated start. Comments for code here: http://www.tidev.io/2015/01/06/how-to-re-use-the-launch-image-in-the-app
var img = Ti.UI.createImageView({
// Get the launch image
image: (function getImage() {
if (OS_IOS) {
// Working around orientation-bug
if (Ti.Platform.osname === 'ipad' || Math.max(Ti.Platform.displayCaps.platformWidth, Ti.Platform.displayCaps.platformHeight) === 736) {
return 'Default-' + (Ti.Gesture.isPortrait() ? 'Portrait' : 'Landscape') + '.png';
} else {
return 'Default.png';
@nielin
nielin / PhoneFormat.js
Created April 20, 2016 22:06 — forked from ckoye/PhoneFormat.js
PhoneFormat.js for Titanium Mobile
/*
Modified version of
https://github.com/albeebe/phoneformat.js/blob/master/PhoneFormat.js
Made it Titanium-Mobile-ready by adding the exports for each function here.
http://www.phoneformat.com
*/
@nielin
nielin / Version.m
Created April 3, 2016 17:25 — forked from alex-cellcity/Version.m
Runtime iOS Version Checking
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@nielin
nielin / gist:902d588fcb7ad8b9a47f5f3ac31b2674
Created April 1, 2016 22:17 — forked from furi2/gist:1378595
Uploading multipart/form-data type data from Titanium
var content = '';
var boundary = '---------------------------170062046428149';
content += '--'+ boundary + '\r\n';
content += 'Content-Disposition: form-data; name="uploadToken"\r\n';
content += '\r\n';
content += upload_token + '\r\n';
content += '--'+ boundary + '\r\n';
content += 'Content-Disposition: form-data; name="destFolderPath"\r\n';
content += '\r\n';
@nielin
nielin / collabsablerows.js
Created March 27, 2016 15:28 — forked from rileydutton/collabsablerows.js
Collapsable/Expandable Table View Rows in Titanium Mobile
var container = Ti.UI.createView({backgroundColor: "white", layout: "vertical"});
var layout = [
{
title: "Parent 1",
isparent: true,
opened: false,
sub: [
{