Skip to content

Instantly share code, notes, and snippets.

View camsong's full-sized avatar
🤖
GPTing

Cam Song camsong

🤖
GPTing
View GitHub Profile
@camsong
camsong / 1 - script.js
Created September 30, 2015 02:57 — forked from callahad/0 - README.md
ES7 Async to ES6 via Babel
// $ cat script.js
async function foo() {
res = await fetch("https://example.com");
return res.ok;
}
@camsong
camsong / introrx.md
Created September 25, 2015 07:20 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
return cloneWithProps(
React.Children.only(this.props.children),
{className: 'disabled'}
);
@camsong
camsong / gist:50f334099fc39e26d54b
Created September 22, 2014 06:49
react-router-link-1.js
this.props.onClick = function(e) {
e.preventDefault();
};
var link = Link(this.props);
// how to implement the /if match current path/ part?
var App = React.createClass({
render: function() {
return (
<div>
<header>
<ul>
<li isActive={/if match current path/}><Link to="app">Dashboard</Link></li>
@camsong
camsong / binary-field-exception
Created May 16, 2014 06:23
exception got when save binary field to sql server: undefined method `[]' for nil:NilClass
activerecord (4.1.1) lib/active_record/relation/delegation.rb:9:in `relation_delegate_class'
activerecord (4.1.1) lib/active_record/relation/delegation.rb:112:in `relation_class_for'
activerecord (4.1.1) lib/active_record/relation/delegation.rb:106:in `create'
activerecord (4.1.1) lib/active_record/model_schema.rb:133:in `table_name='
activerecord (4.1.1) lib/active_record/model_schema.rb:148:in `reset_table_name'
activerecord (4.1.1) lib/active_record/model_schema.rb:109:in `table_name'
arjdbc/jdbc/RubyJdbcConnection.java:1308:in `update_lob_value'
activerecord-jdbc-adapter (1.3.7) lib/arjdbc/jdbc/adapter.rb:615:in `update_lob_value'
activerecord-jdbc-adapter (1.3.7) lib/arjdbc/util/serialized_attributes.rb:22:in `update_lob_columns'
org/jruby/RubyArray.java:1613:in `each'
@camsong
camsong / application_controller.rb
Last active August 29, 2015 14:01
CORS enabled in Rails 4
class ApplicationController < ActionController::Base
before_action :cors_set_access_control_headers
def options
head :ok
end
private
def default_serializer_options
{ root: false }
@camsong
camsong / CnBeta Ad Cleaner
Created March 5, 2014 13:43
删除CnBeta上的广告
$('.main_content_right section:not(:first)').remove()
$('section:first').remove()
$("div[id^='BAIDU']").remove()
$("div[id^='googleAd']").remove()