Skip to content

Instantly share code, notes, and snippets.

View javi-moralesf's full-sized avatar

Javi Morales javi-moralesf

View GitHub Profile
@javi-moralesf
javi-moralesf / gist:a731a986de75448511af
Created November 20, 2015 13:16 — forked from icodeforlove/gist:868532
querySelectorAll for anything less than IE8
// IE7 support for querySelectorAll in 226 bytes... It's a little slow but better than a 20kb solution when you need something cross platform and lightweight.
(function(d){d=document,a=d.styleSheets[0]||d.createStyleSheet();d.querySelectorAll=function(e){a.addRule(e,'f:b');for(var l=d.all,b=0,c=[],f=l.length;b<f;b++)l[b].currentStyle.f&&c.push(l[b]);a.removeRule(0);return c}})()
var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({
host: 'localhost',
port: 9090
});
server.route([
{
location /nginx_status {
stub_status on;
access_log off;
allow 188.226.130.98;
deny all;
}
#!/bin/bash
EVENTS="CREATE,DELETE,MODIFY,MOVED_FROM,MOVED_TO"
inotifywait -e "$EVENTS" -m -r --format '%:e %f' /var/www/cdn/files/ | (
WAITING="";
while true; do
LINE="";
read -t 1 LINE;
if test -z "$LINE"; then
package com.moralesf.masquerade;
import android.content.Context;
import android.content.SharedPreferences;
import com.moralesf.masquerade.android.data.MasqueradeApi;
import retrofit.RestAdapter;
public class ApiHelper {
Context context;
private MasqueradeApi api;
public class UserRegisterResponse {
public Boolean result;
public String message;
public String token;
public int user_id;
}
public class UserRegisterRequest {
final String regid;
final String os;
final String device;
public UserRegisterRequest(String regid, String os, String device) {
this.regid = regid;
this.os = os;
this.device = device;
}
...
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(context.getString(R.string.api_host))
.build();
api = restAdapter.create(MasqueradeApi.class);
api.userRegister(new UserRegisterRequest("MyregId-adde3d2", "Android", "Nexus 5"))
.subscribe(new Action1<UserRegisterResponse>() {
dependencies {
...
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'io.reactivex:rxjava:1.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
...
}
import retrofit.http.Body;
import retrofit.http.Header;
import retrofit.http.POST;
import rx.Observable;
public interface MasqueradeApi {
@POST("/user/register")
Observable<UserRegisterResponse> userRegister(@Body UserRegisterRequest body);