Skip to content

Instantly share code, notes, and snippets.

@ghsyeung
ghsyeung / Scraper Motivation.js
Created November 20, 2018 20:21
Dependency Injection
import fetch from "fetch";
class WebScraper {
public download(link) {
const page = fetch(link);
if (page.status === "OK") {
this.cache.add(link, page);
} else {
this.scheduler.schedule(link);
}
@ghsyeung
ghsyeung / Adding Yarn to alpine-node
Last active February 10, 2017 00:50
Installing Yarn in Alpine
Both approaches from https://github.com/yarnpkg/yarn/issues/1326
@ghsyeung
ghsyeung / Dependency Injection Distilled
Last active January 4, 2017 04:43
Dependency Injection Distilled
.
interface FirebaseQuery {
/**
* Listens for data changes at a particular location.
*/
on(eventType: string, callback: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: (error: any) => void, context?: Object): (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void;
}
interface Firebase extends FirebaseQuery {
/**
* Generates a new child location using a unique name and returns a Firebase reference to it.
/// <reference path="../../tools/typings/firebase/firebase.d.ts"/>
module Chat {
class ChatMessage {
constructor(public name:string, public text:string) {
}
}
export class ChatEngine {
private static baseUrl = "<Your Firebase URL>";
private firebase;
> tsd install firebase --save # Install the firebase definition
> tsd reinstall # Reinstall according to tsd.json
@ghsyeung
ghsyeung / gulp-compile.js
Last active August 29, 2015 14:19
Typescript hands on
gulp.src(sourceTsFiles)
.pipe(sourcemaps.init())
.pipe(tsc({
target: 'ES5',
declarationFiles: false,
noExternalResolve: true,
typescript: require('typescript') // Only required if you override the default typescript dependency
}));
@ghsyeung
ghsyeung / designer.html
Last active August 29, 2015 14:12
designer
<link rel="import" href="../yt-video/yt-search-video.html">
<polymer-element name="my-element">
<template>
<style>
#yt_search_video {
width: 300px;
height: 300px;
left: 350px;
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@ghsyeung
ghsyeung / gist:2559116
Created April 30, 2012 15:11
Oracle useful commands
select default_tablespace, temporary_tablespace
from dba_users
where username = 'g'
select sum(bytes) from dba_segments where owner='g'
select * from dba_segments where owner='g'
select * from dba_segments where owner='g'
select * from dba_free_space where tablespace_name = 'USERS' order by bytes desc
ALTER TABLESPACE USERS ADD DATAFILE '/oracle/product/11.1.0/oradata/ORA11G/users02.dbf' SIZE 5242880 AUTOEXTEND ON NEXT 268435456 MAXSIZE 65535M