Skip to content

Instantly share code, notes, and snippets.

View jasonweng's full-sized avatar

jason jasonweng

  • The Plant
  • Hangzhou China
View GitHub Profile
@superKalo
superKalo / Sortable.jsx
Last active August 9, 2022 09:31
How to use jQuery UI with React JS? You can use this approach to integrate almost any jQuery plugin! Full details and explanation here: http://stackoverflow.com/a/40350880/1333836
class Sortable extends React.Component {
componentDidMount() {
// Every React component has a function that exposes the
// underlying DOM node that it is wrapping. We can use that
// DOM node, pass it to jQuery and initialize the plugin.
// You'll find that many jQuery plugins follow this same pattern
// and you'll be able to pass the component DOM node to jQuery
// and call the plugin function.
@ghinda
ghinda / object-to-form-data.js
Last active September 17, 2024 05:22
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@chrisb
chrisb / gist:4d6a09c6cc1ca2e1b14e
Last active November 25, 2022 04:15
Homebrew, Ruby, and Rails on OS X 10.10

OS X 10.10 Guide

Here's what I did to get things working.

1. Install Xcode 6

Yep, over at: https://developer.apple.com

2. Install the Command Line Tools (CLT)

@kejyun
kejyun / RegCheck.js
Created December 17, 2012 14:53
JavaScript正規表示式資料檢測
var RegCheck = {
/**
* 正規表示式
*/
_reg:{
// Email正規表示式
email: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
// 非「英文大小寫」和「數字」出現過一次
not_en_digital_least1: /[^a-zA-Z0-9]+/,
// 「英文大小寫」和「數字」各出現過一次(a1,b2...)
@getify
getify / test.js
Created August 16, 2012 21:25
object JSON serialization that's circular-ref safe
// all this `toJSON()` does is filter out any circular refs. all other values/refs,
// it passes through untouched, so it should be totally safe. see the test examples.
// only extend the prototype if `toJSON` isn't yet defined
if (!Object.prototype.toJSON) {
Object.prototype.toJSON = function() {
function findCircularRef(obj) {
for (var i=0; i<refs.length; i++) {
if (refs[i] === obj) return true;
}
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@jasonweng
jasonweng / README.md
Created December 9, 2011 07:21 — forked from chrisjacob/README.md
Node.js Install + CoffeeScript + LESS (+TextMate Bundles)
@fundon
fundon / array_distinct.js
Created July 29, 2011 06:30
array distinct , JavaScript
//http://lijing00333.wordpress.com/2011/02/08/%E6%95%B0%E7%BB%84%E5%8E%BB%E9%87%8D%E2%80%94%E2%80%94%E4%B8%80%E9%81%93%E5%89%8D%E7%AB%AF%E6%A0%A1%E6%8B%9B%E8%AF%95%E9%A2%98/
// [1,2,2,2,3,4,5].toString().match(/(\d)(?!.*,\1)/g);
Array.prototype.distinct = function() {
var o = {}, i = 0, l = this.length;
for (; i < l;) {
if (!o.hasOwnProperty(this[i])) {
o[this[i++]] = 1;
} else {
this.splice(i, 1);
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}