Skip to content

Instantly share code, notes, and snippets.

@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);
// 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);
package main
import (
spark "github.com/julianshen/SparkGo"
"time"
)
func main() {
core := spark.SparkCore{"YOUR_ACCESS_TOKEN","DEVICE_ID"}
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;
/*
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;
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;
@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;
@julianshen
julianshen / SimpleCellLayout.java
Last active December 19, 2015 00:29
init of SimpleCellLayout
public SimpleCellLayout(Context context, AttributeSet attrs) {
super(context, attrs);
initFromAttributes(context, attrs);
}
public SimpleCellLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initFromAttributes(context, attrs);
@julianshen
julianshen / attrs.xml
Created June 26, 2013 17:08
Attributes of SimpleCellLayout
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SimpleCellLayout">
<attr name="col" format="integer"/>
<attr name="row" format="integer"/>
<attr name="gapsize" format="dimension"/>
<attr name="colspan" format="integer"/>
<attr name="rowspan" format="integer"/>
<attr name="cellX" format="integer"/>
<attr name="cellY" format="integer"/>
@julianshen
julianshen / activity_main.xml
Last active December 19, 2015 00:29
Attributes of SimpleCellLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:celllayout="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.jlnshen.widget.celllayout.SimpleCellLayout
android:layout_width="match_parent"
android:layout_height="match_parent"