Skip to content

Instantly share code, notes, and snippets.

@JaosnHsieh
JaosnHsieh / Rounding
Created July 11, 2016 13:03
ES6 and older version
//es6
const fixMe = (num, fix) => Math.round(num * 10 ** fix) / (10 ** fix)
fixMe(48.48-66.11111111, 2)
//older version
var fixme=function(num, fix) {
var answer = Math.round(num*Math.pow(10, fix))/(Math.pow(10, fix));
console.log(answer);
};
fixme(1/3, 8); //=>0.33333333 (8 decimal places)
@JaosnHsieh
JaosnHsieh / localStorage.html
Created October 21, 2016 06:02 — forked from sagar-ganatra/localStorage.html
Local storage event listeners
<!DOCTYPE html>
<html>
<head>
<title>localStorage Test</title>
<script type="text/javascript" >
var count = 0;
var storageHandler = function () {
alert('storage event 1');
};
var ids = {
github: {
clientID: 'Go github.com , click your avatar -> settings ->oauth application->set callback and application url ->',
clientSecret: '*****',
callbackURL: "http://localhost:3000/login/auth/github/callback"
},
google:{
clientID: 'Google API console -> create a project -> create your credentails -> set callback and application url ->enable google+ api',
clientSecret: '******',
callbackURL: "http://localhost:3000/login/auth/google/callback"
@JaosnHsieh
JaosnHsieh / index.html
Created July 17, 2017 10:38 — forked from anonymous/index.html
Slot Machine
<html>
<head>
<link href="style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Asset" rel="stylesheet">
</head>
<body>
<div id = "space">
<div id="container1">
<div class="div1"><img src="https://247wallst.files.wordpress.com/2015/05/thinkstockphotos-158403411.jpg?w=200"></div>
<div class="div2"><img src="http://2.wlimg.com/product_images/bc-small/dir_115/3420934/fresh-orange-1671496.jpg"></div>
@JaosnHsieh
JaosnHsieh / facebook-login.sh
Created April 12, 2018 10:43 — forked from hubgit/facebook-login.sh
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
import * as actions from "./actions.js";
const mapStateToProps = (state, ownProps) => ({
test: state.test,
result: state.result,
loading: state.loading
});
const mapDispatchToProps = (dispatch, ownProps) => ({
addOne: () => {
@JaosnHsieh
JaosnHsieh / facebook-login.sh
Created April 19, 2018 09:37 — forked from rajapaju/facebook-login.sh
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
@JaosnHsieh
JaosnHsieh / flash-app.js
Created May 13, 2018 03:06 — forked from brianmacarthur/flash-app.js
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@JaosnHsieh
JaosnHsieh / appEntryPoint.js
Created May 13, 2018 13:44 — forked from markerikson/appEntryPoint.js
Webpack React/Redux Hot Module Reloading (HMR) example
import React from "react";
import ReactDOM from "react-dom";
import configureStore from "./store/configureStore";
const store = configureStore();
const rootEl = document.getElementById("root");
@JaosnHsieh
JaosnHsieh / firedns.js
Created May 27, 2018 11:40 — forked from vikrum/firedns.js
A custom DNS server in NodeJS that saves off queries to Firebase so they can be retrieved later. Accompanying blog post: http://5f5.org/ruminations/dns-debugging-over-http.html
var crypto = require('crypto');
var dns = require('native-dns');
var rest = require('restler');
var server = dns.createServer();
server.on('request', function (request, response) {
var domain = request.question[0].name;
if(domain == 'webutils.flourishworks.com') {
// Don't log this because it can't be uniquely identified and subsequently retrieved