Skip to content

Instantly share code, notes, and snippets.

View Daniel-Xu's full-sized avatar

Daniel_Xu Daniel-Xu

View GitHub Profile
import Ember from 'ember';
import { task, timeout, asyncComputed } from 'ember-concurrency';
export default Ember.Controller.extend({
query: "",
searchResults: asyncComputed('query', function * (query) {
if (Ember.isBlank(query)) { return []; }
yield timeout(500);
let url = `https://api.github.com/search/repositories?q=${query}`;
@Daniel-Xu
Daniel-Xu / 0_reuse_code.js
Created October 18, 2016 01:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
hello(firstArg, { target: { value } }) {
console.log(value);
console.log(arguments);
}
func crackPop() {
for i in 1...100 {
if i%15 == 0 {
println("CracklePop")
} else if i%3 == 0{
println("Crackle")
} else if i%5 == 0 {
println("Pop")
@Daniel-Xu
Daniel-Xu / ios simulator path
Created June 3, 2014 04:36
open simulator path
open ~/Library/Application\ Support/iPhone\ Simulator/
require 'bundler/setup'
require 'mechanize'
require 'open-uri'
agent = Mechanize.new
# agent.set_proxy 'localhost', 3128
# login
agent.get('https://www.codeschool.com/users/sign_in') do |page|
result = page.form_with(:action => '/users/sign_in') do |form|
@Daniel-Xu
Daniel-Xu / gist:ac062c5881f6f8800b48
Created May 29, 2014 13:13
install redis on macos

using homebrew

brew install redis

how to start

After you install the redis, there's will be several instructions below the command brew install redis, basically it use

launchctl, so make sure you start the redis-server

remove old database files (this is dangerous, make sure you don't have any data in your database)

rm -rf /usr/local/var/postgres

install the binary

brew install postgresql

init it

initdb /usr/local/var/postgres

start the postgres server

@Daniel-Xu
Daniel-Xu / gist:d67dd7c8247a2c17c273
Created May 14, 2014 07:20
javascript functional scope
var i = 1
for(var i = 0; i < 10; ++i){}
console.log(i)
var y = "glo"
function printy(){
console.log(y)
}
function test(y)
{
var y = "inner"
printy()