Skip to content

Instantly share code, notes, and snippets.

View hongbo-miao's full-sized avatar
❣️

Hongbo Miao hongbo-miao

❣️
View GitHub Profile
@PatrickJS
PatrickJS / api.service.ts
Last active September 18, 2017 18:07
Universal Cache
// Something like this. I haven't tested this file
@Injectable()
export class ApiService {
constructor(public _http: Http, public _cache: Cache) {
}
// whatever domain/feature method name
getModel(url) {
// you want to return the cache if there is a response in it. This would cache the first response so if your API isn't idempotent you probably want to remove the item from the cache after you use it. LRU of 1
@randallreedjr
randallreedjr / .elsintrc.js
Created October 13, 2016 14:50
ESLint config file extending local configuration
module.exports = {
  “extends”: “../src/.eslintrc.js”,
  “rules”: {
  “import/no-extraneous-dependencies”: “error”
  }
};
@devCrossNet
devCrossNet / app.component.html
Last active October 10, 2016 16:09
Content-Outlet for Angular 2 Applications. Change multiple components with the help of routing
./src/app/app.component.html
<md-sidenav-layout>
<md-toolbar color="primary">
<span>
Brand
</span>
<app-content-outlet [id]="'topnav'"></app-content-outlet>
<button md-icon-button (click)="sidenav.toggle()">
<md-icon>menu</md-icon>

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
@stubailo
stubailo / graphql-subscriptions-client.js
Created October 2, 2016 16:51
Use subscriptions-transport-ws to run a GraphQL subscription from a JavaScript client.
// To run this code yourself:
// 1. Download and run the demo server: https://github.com/apollostack/frontpage-server
// 2. Use create-react-app to create a build system
// 3. npm install subscriptions-transport-ws
// 4. Replace all of the code in src/ with just this file
import { Client } from 'subscriptions-transport-ws';
const client = new Client('ws://localhost:8090');
@gaearon
gaearon / quiz.md
Last active January 11, 2024 16:56

A top-level App component returns <Button /> from its render() method.

  1. What is the relationship between <Button /> and this in that Button’s render()?

  2. Does rendering <Button><Icon /></Button> guarantee that an Icon mounts?

  3. Can the App change anything in the Button output? What and how?


/*
* Be sure to drink your Ovaltine
*
* If you are a JavaScript nerd supreme:
*/
/*
* ...should all output "true"
*
* bonus for avoiding for loops
@toddmotto
toddmotto / *.js
Created September 19, 2016 19:41
Angular function arguments
(function(A,n,g,u,l,a,r){A.GoogleAnalyticsObject=r;A[l]=A[l]||function(){
(A[l].q=A[l].q||[]).push(arguments)},A[l].l=1*new Date();a=n.createElement(g),
r=n.getElementsByTagName(g)[0];a.async=1;a.src=u;r.parentNode.insertBefore(a,r)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-XX', 'auto');
ga('send', 'pageview');
@CodeMyUI
CodeMyUI / index.html
Created September 13, 2016 02:42
React DailyUI - 015 - On/Off Toggle Switch
<div id="switch"></div>
@CodeMyUI
CodeMyUI / animated-css-dusk.markdown
Created September 12, 2016 13:53
Animated CSS Dusk

Animated CSS Dusk

This sample was made to demonstrate (in a more exaggerated way) how CSS transforms and transitions can be leveraged to create complex effects. This demo also shows how to animate linear gradients despite lack of css support by transitioning opacities between 2 layers.

A Pen by Dacheng aka dSolver on CodePen.

License.