Skip to content

Instantly share code, notes, and snippets.

View shengoo's full-sized avatar

shengoo

  • Beijing, China
View GitHub Profile
@shengoo
shengoo / scrolltotop.js
Created October 25, 2016 07:15
scroll to top
window.scrollTo(0, 0);
$('body, html').animate({ scrollTop: 0 }, 800); // 800 - animation length; IMHO, most optimal :)
@shengoo
shengoo / StretchVideoView.java
Created May 1, 2016 06:23 — forked from raultm/StretchVideoView.java
Android : How to stretch video to use whole area of VideoView (sode snippets)
package com.raulete.dev.stretchvideoview.utils;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;
public class StretchVideoView extends VideoView {
public StretchVideoView(Context context) {
super(context);
}
@shengoo
shengoo / Android Studio .gitignore
Created April 10, 2016 16:53 — forked from iainconnor/Android Studio .gitignore
A .gitignore for use in Android Studio
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@shengoo
shengoo / npm-global-without-sudo.md
Created July 15, 2015 05:10
npm-global-without-sudo.md

Install npm packages globally without sudo on OS X and Linux

npm installs packages locally within your projects by default. You can also install packages globally (e.g. npm install -g <package>) (useful for command-line apps). However the downside of this is that you need to be root (or use sudo) to be able to install globally.

Here is a way to install packages globally for a given user.

1. Create a directory for your global packages
mkdir "${HOME}/.npm-packages"
@shengoo
shengoo / get url query string.js
Created December 23, 2014 06:27
Get url query string
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@shengoo
shengoo / common_module.js
Created December 3, 2014 06:35
angularjs shared module
"use strict";
// make a common module
angular.module("common",[])
.filter("someFilter", function (){
return function (text) {
return text;
};
});
@shengoo
shengoo / angularjs datasource.js
Created November 27, 2014 09:22
Kendo UI DataSource work with angular js service
angular.module("app", ["kendo.directives"])
.controller("news", function($scope,newsService) {
var dataSource = new kendo.data.DataSource({
transport: {
read: dataSourceRead
}
});
function dataSourceRead(options){
//todo: show loading
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Using The $http Service In AngularJS To Make AJAX Requests
</title>
<style type="text/css">
@Override
public void onDestroy() {
super.onDestroy();
// Restart service in 500 ms
((AlarmManager) getSystemService(Context.ALARM_SERVICE))
.set(AlarmManager.RTC,
System.currentTimeMillis() + 500,
PendingIntent.getService(this, 3, new Intent(this, TaskService.class), 0));
}