Skip to content

Instantly share code, notes, and snippets.

@codephillip
codephillip / node-and-npm-in-30-seconds.sh
Last active August 29, 2015 14:26 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@codephillip
codephillip / SearchBar.java
Created October 12, 2015 14:22 — forked from philipbjorge/SearchBar.java
Android Asynchronous ContentProvider - Search as you type
package edu.wwu.cs412.tvfanatic;
import edu.wwu.cs412.tvfanatic.account.AccountPreferenceActivity;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.app.SearchManager;
import android.app.FragmentManager.BackStackEntry;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@codephillip
codephillip / Application.java
Created March 2, 2017 08:17 — forked from raffaeleguidi/Application.java
A simple file upload and renderBinary example using Play! 1.2.3 and GAE (google appengine) 1.5.6
package controllers;
import play.*;
import play.data.Upload;
import play.db.Model.BinaryField;
import play.libs.MimeTypes;
import play.mvc.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
<form name="form" ng-submit="couctrl.verifyCode()" role="form" >
<!--<select class="login-select" ng-model="couctrl.statusChoice" ng-change="couctrl.onValueChange()">-->
<!--<optgroup label="Status">-->
<!--<option value="12" selected="">Delivered</option>-->
<!--<option value="13">Not Delivered</option>-->
<!--</optgroup>-->
<!--</select>-->
<span>Status</span>
<select
@codephillip
codephillip / CustomListCreateApi.py
Created August 2, 2017 14:52
ListCreateAPIView in django rest framework with different serializer for the GET and POST
from rest_framework import generics, status
from rest_framework.response import Response
from rack.models import RackItem
from rack.serializers import RackItemSerializer, NewRackItemSerializer
class ListCreateRackItem(generics.ListCreateAPIView):
model = RackItem
https://github.com/afollestad/material-dialogs
https://github.com/pedant/sweet-alert-dialog
#tip dialog
https://github.com/michaelye/EasyDialog
@codephillip
codephillip / ClassVsStructure
Created September 22, 2017 09:09
Class vs Structure difference in swift. Structures provide better threading functionality
import UIKit
/*
CREDIT: http://agostini.tech/2017/09/03/structures-vs-classes-in-swift/
*/
// MARK: - Structures Example
struct Book {
var title: String
var author: String
}
https://maps.googleapis.com/maps/api/directions/json?origin=0.3181614,32.5736069&destination=0.3184610990987622,32.55381792783737&sensor=false&mode=driving
// Method 1
String MAP_BASE_URL = "https://maps.googleapis.com/maps/api/directions/json?";
Uri.Builder builtUri = Uri.parse(MAP_BASE_URL)
.buildUpon()
.appendQueryParameter("origin", origin.latitude + "," + origin.longitude)
.appendQueryParameter("destination", dest.latitude + "," + dest.longitude)
.appendQueryParameter("sensor", "false")
.appendQueryParameter("mode", "driving");
@codephillip
codephillip / curl.md
Created November 21, 2017 12:28 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

class TestTable(ndb.Model):
fb_page_id = ndb.StringProperty()
date = ndb.StringProperty()
step = ndb.IntegerProperty()
if not isLocal():
from google.appengine.ext import ndb