Skip to content

Instantly share code, notes, and snippets.

View weixiyen's full-sized avatar

Weixi Yen weixiyen

View GitHub Profile
User
|> prepared(user_id: user_id, username: username)
|> insert(user_id: :user_id, username: :username)
|> if_not_exists
|> User.save
User
|> update(username: username)
|> where(user_id: user_id)
|> constrain(username: previous_username)
User
|> prepared(user_id: id)
|> select([:user_id, :username])
|> where(user_id: :user_id)
|> User.one
User
|> select([:user_id, :username])
|> where(user_id: [in: [1, 2, 3]])
|> limit(10)
defmodule Schema.UserByEmail do
require Schema.User # if you want to auto-create at compile time
use Triton.MaterializedView
materialized_view :users_by_email, from: Schema.User do
fields [
:user_id,
:email,
:display_name,
:password
defmodule Schema.User do
require Schema.Keyspace
use Triton.Table
table :users, keyspace: Schema.Keyspace do
field :user_id, :bigint, validators: [presence: true] # validators using vex
field :username, :text
field :display_name, :text
field :password, :text
field :email, :text
//
// FFVerifyLocationViewModel.m
// Blitz
//
// Created by Sunny Kang on 9/1/14.
// Copyright (c) 2014 Blitz. All rights reserved.
//
#import "FFVerifyLocationViewModel.h"
#import <CoreLocation/CoreLocation.h>
@weixiyen
weixiyen / gist:9197399
Last active August 29, 2015 13:56
Week 3

Week 3 Summary

Lunar Revel Battle of 2-0 Teams

  • storm8 (3-0) def factset (2-1)
  • nerdery (3-0) def google sapphire (2-1)
  • amazon prime (3-0) def microsoft spaceland (2-1)
  • curse tibbers (3-0) def raytheon (2-1)
@weixiyen
weixiyen / gist:1250090
Created September 29, 2011 06:07
Push server with Redis Subscriber
require.paths.unshift(process.cwd() + '/lib')
require.paths.unshift(process.cwd() + '/contrib')
redis = require 'redis'
settings = require('settings').stream
# DEFAULT SETTINGS
# -------------------------------------------------
settings.port = process.argv[2] if process.argv[2]?
io = require('socket.io').listen Number(settings.port)
###
Async.js is a collection of simple async patterns
built to combat callback hell
###
###
ASYNC SEQUENCE
Allows a user to define a sequence of async functions.
EXAMPLE:
async = require 'async'
(function($){
var opts = {},
default_opts = {
url: '',
refresh: 1000,
paramname: 'userfile',
maxfiles: 25,
maxfilesize: 1, // MBs
data: {},