Skip to content

Instantly share code, notes, and snippets.

View codemilli's full-sized avatar
😇
Hooked on React Hooks

codemilli codemilli

😇
Hooked on React Hooks
  • Zemilli Design Studio
  • Seoul, South Korea
  • X @codemilli
View GitHub Profile
@codemilli
codemilli / functor-01.js
Created March 5, 2017 07:25
mappable functor
var arr = [ 1, 2, 3, 4 ];
var newArr = arr.map(x => x * 10);
console.log('arr => ', arr);
console.log('newArr => ', newArr);
@codemilli
codemilli / hacky-scrollbar-resize-listener.js
Created February 23, 2017 08:36 — forked from OrganicPanda/hacky-scrollbar-resize-listener.js
A sham that will throw a window resize event even when scrollbars are added/removed (this is not something the standard window resize event does). Tested in IE9+, Chrome & Firefox latest.
// Demo: http://jsfiddle.net/pFaSx/
// Create an invisible iframe
var iframe = document.createElement('iframe');
iframe.id = "hacky-scrollbar-resize-listener";
iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;';
// Register our event when the iframe loads
iframe.onload = function() {
// The trick here is that because this iframe has 100% width
@codemilli
codemilli / js-style-load.md
Last active February 23, 2017 11:44
style load with javascript

Inline CSS

// function scope for moduling
!function() {
  var style = document.createElement('style');
  
  style.innerText = '::-webkit-scrollbar { width: 8px; }';
  document.getElementsByTagName('head')[0].appendChild(style);
//Below is a JavaScript snippet that parses the response and returns the parameters to the server.
// First, parse the query string
var params = {}, queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g, m;
while (m = regex.exec(queryString)) {
params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
// And send the token over to the server
import { Component } from '@angular/core';
@Component({
selector: 'sth',
template: `<h2> Hello {{ title }} </h2>`
})
export class TemplateTestComponent {
title: string = " Something ";
}
import { Injectable } from '@angular/core';
@Injectable()
export class ValueConfig {
title: string;
getTitle(): string {
return this.title;
}
}
@import { Injectable, Component } from '@angular/core';
@Injectable()
export class AService {
// ...
}
@Component({
// ...
providers: [ AService ]
package com.features;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import android.util.Log;
(function() {
window.UAParserBackup = window.UAParser
}).call(this),
function(t) {
"use strict";
var e = t.userAgent = function(t) {
function e(t) {
var e = {},
i = /(dolfin)[ \/]([\w.]+)/.exec(t) || /(chrome)[ \/]([\w.]+)/.exec(t) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(t) || /(webkit)(?:.*version)?[ \/]([\w.]+)/.exec(t) || /(msie) ([\w.]+)/.exec(t) || t.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(t) || ["", "unknown"];
return "webkit" === i[1] ? i = /(iphone|ipad|ipod)[\S\s]*os ([\w._\-]+) like/.exec(t) || /(android)[ \/]([\w._\-]+);/.exec(t) || [i[0], "safari", i[2]] : "mozilla" === i[1] ? /trident/.test(t) ? i[1] = "msie" : i[1] = "firefox" : /polaris|natebrowser|([010|011|016|017|018|019]{3}\d{3,4}\d{4}$)/.test(t) && (i[1] = "polaris"), e[i[1]] = !0, e.name = i[1], e.version = n(i[2]), e
var observableStream = Rx.Observable.create(function(observer) {
observer.onNext(1);
});
var subscriber = observableStream.subscribe(function(data) {
console.log('data', data);
if (data) {
subscriber.dispose();
}