Skip to content

Instantly share code, notes, and snippets.

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

Hongbo Miao hongbo-miao

❣️
View GitHub Profile
import { ApolloStore } from 'apollo-client';
import { Store } from '@ngrx/store';
import { skip } from 'rxjs/operator/skip';
import { take } from 'rxjs/operator/take';
export function toApolloStore(store: Store<any>): ApolloStore {
return {
subscribe(fn: () => void): () => void {
const futureStates$ = skip.call(store, 1);
""" The problem description:
Given a Data Structure having first n integers and next n chars.
A = i1 i2 i3 ... iN c1 c2 c3 ... cN.Write an in-place algorithm
to rearrange the elements of the array ass A = i1 c1 i2 c2 ... in cn
"""
def swap(arr, ind1, ind2):
@lyyourc
lyyourc / RxJS 5 Operators By Example.md
Last active June 3, 2017 12:57
「译」RxJS 5 Operators By Example
@jack-guy
jack-guy / feathers.d.ts
Last active September 7, 2017 10:34
These are basic typings for Feathers.js based off of those in DefinitelyTyped for Express. This doesn't type feathers plugins, but does have some interfaces that can be used in them. WIP.
// Type definitions for Feathers
// Project: http://feathersjs.com/
// Definitions by: Jack Guy <http://thatguyjackguy.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Application, Handler, ErrorRequestHandler } from 'express';
type HandlerArgument = Handler | Handler[];
export = Feathers;
@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
@tomitrescak
tomitrescak / meteor.d.ts
Created March 2, 2016 23:14
Typescript definition for Meteor 1.3
// Type definitions for Meteor 1.3
// Project: http://www.meteor.com/
// Definitions by: Dave Allen <https://github.com/fullflavedave>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* These are the common (for client and server) modules and interfaces that can't be automatically generated from the Meteor data.js file
*/
interface EJSONable {
@ndastur
ndastur / log.js
Last active March 26, 2018 14:42
Server and Client side logging in Meteor using Winston
/*
Add package:
meteor add votercircle:winston
Then use in server or client code as
logger.[debug|info|warn|error]
*/
if(Meteor.isServer) {
//- Ref: https://atmospherejs.com/votercircle/winston
//- Setup Winston logging
@alonronin
alonronin / gist:5545119
Created May 9, 2013 02:19
node.js mongoose random documents
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var schema = new mongoose.Schema({
name: String,
email: String,
random: {type: [Number], default: function(){ return [Math.random(), Math.random()]}, index: '2d'}
});
@yuturiy
yuturiy / Messenger.js
Last active January 4, 2019 13:45
Messenger for React
// USING:
// import Messenger from './Messenger'
// <Messenger news={['your', 'array', 'with', 'strings', 'here']}/>
import React, { Component } from "react";
export default class Messenger extends Component {
state = {
mainMessage: "",
codeletters: "&#*+%?£@§$",