Skip to content

Instantly share code, notes, and snippets.

View yhsiang's full-sized avatar
🙅‍♂️
それだめ

LY Cheng yhsiang

🙅‍♂️
それだめ
View GitHub Profile
@tomchentw
tomchentw / ng-bem.ls
Last active August 29, 2015 14:02
ng-bem proposal
# http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
#
# .site-search {} /* Block */
# .site-search__field {} /* Element */
# .site-search--full {} /* Modifier */
#
#
angular.module 'ng-bem' []
.directive 'bem-block' ->
BemBlockCtrl.$inject = [
#!/usr/bin/env node
var esprima = require('esprima');
var estraverse = require('estraverse');
var escodegen = require('escodegen');
var fs = require('fs');
var _ = require('lodash');
var file = fs.readFileSync('./actions.js', 'utf-8');
var tree = esprima.parse(file);
@jhorneman
jhorneman / async data loading in Flux.md
Last active August 22, 2016 02:18
Thoughts on where to do async data loading in Flux

Async data loading in Flux

I've been working with Flux a lot recently, and one of the questions I've been struggling with is in which part of the Flux cycle to put my asynchronous data requests.

Here are some different opinions:

The diagram

The famous Flux diagram puts them in the action creators.

The chat example

@jhorneman
jhorneman / problems with Flux.md
Last active August 22, 2016 02:18
How to combine the Flux pattern with large hierarchical data

How to combine the Flux pattern with large hierarchical data

I've been converting the web client part of an application I'm developing for a client from plain old JavaScript to React and Flux. (Because this is closed-source client work, I will be a bit vague about what the application is and does.)

Something about my data, my use case, and how I've implemented things, or some combination of those three, doesn't fit the Flux pattern well. So I am writing this to explain my problem and hopefully get some interesting feedback on it. (If you're reading this: thanks.)

The application

I have a Python server which talks to a PostgreSQL database and provides data in JSON format over a REST-ish API (not pure REST, more RPC-style).

|-------------------------------------------------------------------------------------------------------|
| Library | Insert | findPk | complex| hydrate| with | memory usage | time |
| --------------------------------:| ------:| ------:| ------:| ------:| ------:| ------------:| ------:|
| PDO | 72 | 12 | 29 | 69 | 220 | 1,689,176 | 0.41 |
| Maghead | 395 | 9 | 176 | 205 | 365 | 10,485,760 | 1.16 |
| | | | | | | | |
| LessQL | 366 | 70 | 377 | 364 | 363 | 10,078,872 | 1.55 |
| | | | | | | | |
| YiiM | 714 | 86 | 436 | 292 | 614 | 8,388,608 | 2.16 |
| YiiMWithCache | 693 | 83 | 435 | 303
@neoeinstein
neoeinstein / Auth0.elm
Last active March 2, 2017 08:22
Elm Example for interoperating with Auth0. Note that much of this was culled out of an existing code-base, so may need some minor edits to work correctly for you. Presumes that Elm.Main is transpiled into elm.js
module Auth0
( AuthenticationState(..), AuthenticationError, AuthenticationResult
, Options, defaultOpts
, LoggedInUser, UserProfile, Token
, showLock, showLockSignal
, mapResult
) where
@jstcki
jstcki / README.md
Last active April 12, 2017 13:24
Transitions with React and D3 II

Using D3 in a React TransitionGroup to transition elements. D3 is used purely for transitions, not for data joins. The distinction between entering and exiting elements is handled by the TransitionGroup component. See the React documentation for further information.

Alternative implementations only with D3 and using React without addons.

Note: This implementation is around 30% slower in processing 1000 circles than the other two.

@treyrich
treyrich / Example.js
Last active May 30, 2017 20:36
This is an AngularJS provider to communicate with a Sails.js backend via Socket.IO.After searching for way too long for a way to interface with the Sails.js client-side SDK included in new Sails projects via AngularJS I decided to write a drop in replacement for the AngularJS $http provider.Although this isn't a full replacement it includes a nu…
angular.module("MyApp", ["SocketProvider"])
.controller("MyController", ["$scope", "socket", function($scope, socket) {
// Fetch initial data
$scope.person = null;
socket.get("/person/1").success(function(data) {
$scope.person = data;
}).error(function() {
@mqli
mqli / Few Line of Hack Code Make React-Native Run on Windows.md
Last active July 13, 2017 19:14
Few Line of Hack Code Make React-Native Run on Windows

#Few Line of Hack Code Make React-Native Run on Windows

While React-Native just add support of Android,yet officeally they just only support on OSX.

After a few hours of debugging, I find a simple way of let React-Native run on Windows.

Make sure all requirements were all setup following this:

Then initilize the project following this:

@haxpor
haxpor / setup_branchio_for_custom_domain.md
Created March 22, 2017 08:11
Setup Branch.io for custom domain.

Two different versions of document as seen in

  1. https://dashboard.branch.io/start/existing-users/ios
  2. https://dev.branch.io/getting-started/sdk-integration-guide/ + https://dev.branch.io/getting-started/universal-app-links/guide/ios/

I followed each one separately for my custom domain (l.pbapp.net) as set in Link Domain section, and at last it doesn't work for me. Tested on iOS 9.3.2. The problem is whenever click on the link, it doesn't take me to the app. But SDK can detect the link I clicked previously when observe in debug log when directly run the app myself. So only "taking-me-to-app" part.

But I did the following to make it work

  1. Include the following in Info.plist