Skip to content

Instantly share code, notes, and snippets.

View xiujunma's full-sized avatar
🎯
Focusing

Xiujun Ma xiujunma

🎯
Focusing
View GitHub Profile
import Ember from 'ember';
const {
getOwner,
setOwner
} = Ember;
let BaseComponent = Ember.Component.extend({
});
var Page = React.createClass({
getInitialState: function() {
return {word: null};
},
componentDidMount: function() {
var ws = new WebSocket("ws://url.com/ws");
var self = this;
ws.onmessage = function(msg) {
self.setState({word: msg});
Ember.CanvasView = Ember.View.extend({
tagName: 'canvas',
attributeBindings: ['width', 'height'],
content: null,
width: 400,
height: 100,
clipsCanvasToDrawRect: true,
clippingRect: null,
redrawScheduled: false,
init: function () {
@xiujunma
xiujunma / gist:5857383
Created June 25, 2013 10:07
add commas to currency
currency_comma = function (str) {
str += '';
var arr = str.split('.'),
integer = arr[0],
fraction = arr.length > 1 ? '.' + arr[1] : '';
var regex = /(\d+)(\d{3})/;
while (regex.test(integer)) {
integer = integer.replace(regex, '$1' + ',' + '$2');
@xiujunma
xiujunma / gist:4367956
Last active December 10, 2015 02:29
find out yyets ed2k url
require 'net/http'
ed2k_url_array = Net::HTTP.get(URI.parse('http://www.yyets.com/php/resource/10733')).scan(/"(ed2k:\/\/.+?)"/)
ed2k_url_array.each { |ed2k_url| puts ed2k_url }