Skip to content

Instantly share code, notes, and snippets.

@julianshen
julianshen / SimpleCellLayout.java
Last active December 19, 2015 00:29
Generate layout parameters
@Override
public LayoutParams generateLayoutParams(AttributeSet attrs) {
return new CellLayoutParams(getContext(), attrs);
}
public static class CellLayoutParams extends MarginLayoutParams {
public int cellX = 0;
public int cellY = 0;
public int cellRowSpan = 1;
public int cellColSpan = 1;
package com.htc.blinkfeed.sample.vimeo.api;
import java.io.IOException;
import java.net.HttpURLConnection;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.basic.DefaultOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// give it a name:
int led = D7;
var SparkCore = require('./spark_core');
var util = require('util');
var juliansCore = new SparkCore({
device_id: 'YOUR_DEVICE_ID',
access_token: 'YOUR_ACCESS_TOKEN'
});
var val = 0;
(function blink() {
val = (val + 1) % 2;
package main
import (
spark "github.com/julianshen/SparkGo"
"time"
)
func main() {
core := spark.SparkCore{"YOUR_ACCESS_TOKEN","DEVICE_ID"}
// give it a name:
int _led = D7;
//function definition
int led(String command);
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(_led, OUTPUT);
@julianshen
julianshen / gist:0c85f482caac64ed26b7
Created August 20, 2014 16:33
shortcut example
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "test");
PackageManager pm = getPackageManager();
ApplicationInfo youtube = null;
ApplicationInfo plus = null;
ApplicationInfo map = null;
try {
youtube = pm.getApplicationInfo("com.google.android.youtube", PackageScanIntentService.FLAGS_PACKAGE);
package main
import (
"encoding/json"
"fmt"
"os"
)
func main() {
type User struct {
package main
import (
"encoding/json"
"fmt"
"os"
)
func main() {
type User struct {
@julianshen
julianshen / a.swift
Last active October 4, 2015 15:41
Array Extension
extension CollectionType where Generator.Element == String {
func find(subString:Generator.Element) -> Int {
for (i,s) in self.enumerate() {
if s.containsString(subString) {
return i
}
}
return -1
}
}