Skip to content

Instantly share code, notes, and snippets.

View lykmapipo's full-sized avatar

lally elias lykmapipo

View GitHub Profile
@lykmapipo
lykmapipo / gist:26204afbfe17f2f3f418316e4ccc227c
Created April 27, 2016 11:59 — forked from klovadis/gist:5170446
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
@lykmapipo
lykmapipo / gist:6a8f56aec23fda81796530ae87b13ec8
Created April 27, 2016 11:59 — forked from klovadis/gist:5170485
A Lua script for Redis that allows you to set hash values based on a dictionary table
-- sets all fields for a hash from a dictionary
local hmset = function (key, dict)
if next(dict) == nil then return nil end
local bulk = {}
for k, v in pairs(dict) do
table.insert(bulk, k)
table.insert(bulk, v)
end
return redis.call('HMSET', key, unpack(bulk))
end
@lykmapipo
lykmapipo / GridStream.js
Created June 18, 2016 09:57 — forked from psi-4ward/GridStream.js
NodeJS MongoDB-GridFS Video range stream example Lets your browser seek/jump wihin the video-playback.
var app = require('express')();
var GridStore = require('mongodb').GridStore;
var ObjectID = require('mongodb').ObjectID;
var MongoClient = require('mongodb').MongoClient;
var Server = require('mongodb').Server;
var dbConnection;
MongoClient.connect("mongodb://localhost:27017/ersatz?auto_reconnect", {journal: true}, function(err, db) {
dbConnection = db;
app.listen(3000);
@lykmapipo
lykmapipo / mongodb_one_to_one_lookup.md
Last active June 22, 2016 10:07
A sample use of MongoDB $lookup to populate single $ref
db.entitlements.aggregate(
  [
    {
      $lookup:{
        from:"customers", 
        localField:"customer",
        foreignField:"_id", 
        as:"customer"
 }
@lykmapipo
lykmapipo / mongodb_one_to_many_lookup.md
Last active June 22, 2016 10:09
A Sample MongoDB $lookup to populate many $ref
db.parties.aggregate(
  [
    {
      $match:{
        "roles":{
            $ne:null // []
          }
        }
 },
@lykmapipo
lykmapipo / setup.md
Last active July 12, 2017 11:59
Setup Custom MongoDB in Travis CI
language: node_js

node_js:
  - "4.0"
  - "4"
  - "5.0"
  - "5"
  - "6.0"
 - "6"
@lykmapipo
lykmapipo / RxJava.md
Created November 30, 2017 22:28 — forked from ZacSweers/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@lykmapipo
lykmapipo / KeyboardUtils.java
Created December 1, 2017 12:00 — forked from marteinn/KeyboardUtils.java
Android utils class for showing and hiding a keyboard.
package se.marteinn.utils;
import android.content.Context;
import android.os.AsyncTask;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
/**
* Created by martinsandstrom on 2014-04-21.