Skip to content

Instantly share code, notes, and snippets.

View lsongdev's full-sized avatar
👨‍💻
Thinking ...

Lsong lsongdev

👨‍💻
Thinking ...
View GitHub Profile
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define PI 3.14159265359
float sx, sy;
float sdCircle(float px, float py, float r) {
float dx = px - sx, dy = py - sy;
@lsongdev
lsongdev / di.html
Last active August 29, 2015 14:12
Dependency injection Demo
<html>
<head>
<title>Dependency injection Demo</title>
<script charset="utf-8">
/**
* [依赖注入核心定义]
* @param {[type]} win [description]
* @param {[type]} undefined [description]
* @return {[type]} [description]
*/
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
@lsongdev
lsongdev / MethodProfiler.js
Created December 17, 2014 05:22
MethodProfiler
var MethodProfiler = function(component) {
this.component = component;
this.timers = {};
this.log = document.createElement("ul");
var body = document.body;
document.getElementById("result").appendChild(this.log);
for(var key in this.component) {
// Ensure that the property is a function.
if(typeof this.component[key] !== 'function') {
continue;
{
"name": "weipai-downloader",
"version": "1.0.0",
"description": "",
"main": "weipai.js",
"author": "lsong",
"license": "MIT",
"dependencies": {
"async": "^0.9.0",
"download": "^3.1.2",
@lsongdev
lsongdev / ntfsutil.sh
Last active August 29, 2015 14:09 — forked from jsfaint/ntfsutil.sh
#!/bin/bash
mount_disk()
{
sudo umount $disk
mkdir ~/Desktop/$diskname
sudo mount_ntfs -o rw,auto,nodev,nobrowse,noowners,noatime $disk ~/Desktop/$diskname
echo "Mount $disk to ~/Desktop/$diskname"
open ~/Desktop/$diskname
}
@lsongdev
lsongdev / underscore-extend.js
Last active August 29, 2015 14:09
underscore-extend.js
_.mixin({
// Return a copy of the object containing all but the blacklisted properties.
unpick: function (obj) {
return _.pick(obj, _.difference(_.keys(obj), _.flatten(Array.prototype.slice.call(arguments, 1))));
},
average: function (arr) {
return _.reduce(arr, function(memo, num){
return memo + num;
}, 0) / arr.length;
}
@lsongdev
lsongdev / auto-like.sh
Created November 5, 2014 08:02
QQ Zone auto like .
#!/usr/bin/env bash
# ~$ ./auto-like.sh AWjSRV4NJ6K1UqL9m4KiH-yf
# ~$ like OK
SID=$1
URL="http://ish.z.qq.com/infocenter_v2.jsp?sid=$SID"
echo $URL
LIKE_URL=`curl -s $URL | grep -o 'http://[^"]*' | grep like_action | sed 's/amp;//g'`
#!/usr/bin/env bash
LATEST_URL="http://nginx.org/download/nginx-1.6.2.tar.gz"
sudo apt-get update
sudo apt-get install libssl-dev
sudo apt-get install zlibc zlib1g zlib1g-dev
wget $LATEST_URL -O /tmp/nginx-latest
<!-- put file in your html -->
<script src="../common/forms/gh-pattern.js"></script>
<script src="../common/forms/gh-unique.js"></script>
<!-- require javascript to app -->
<script type="text/javascript">
angular.module('ghValidation', [ 'ghPattern' ,'ghUnique' ]);
</script>
<!--