Skip to content

Instantly share code, notes, and snippets.

@zhongdeliu
zhongdeliu / scrollToOptions.js
Created August 5, 2019 07:58
Detect if scroll() takes ScrollToOptions
var isSmoothScrollSupported = 'scrollBehavior' in document.documentElement.style;
var scrollToOptions = {
top: 100,
left: 100,
behavior: 'smooth'
};
if (isSmoothScrollSupported) {
// Native smooth scrolling
@zhongdeliu
zhongdeliu / ai.md
Last active July 17, 2017 15:44
List of AI / language understanding web services
min-height: 100%;
background: #9acde2 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAANqklEQ…fzWEFoPVW/J/NjSjomSWGHBnViDGwdVuX7HM3BLx0yGVP+Abekm5AbQE7CAAAAAElFTkSuQmCC);
box-shadow: inset 0 0 18.75em rgba(0,0,0,.5);
@zhongdeliu
zhongdeliu / cookieFunctions.js
Last active August 4, 2016 07:24
Cookie methods
function readCookie(name) {
name += '=';
for (var ca = document.cookie.split(/;\s*/), i = ca.length - 1; i >= 0; i--)
if (!ca[i].indexOf(name))
return ca[i].replace(name, '');
}
// https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework
function readCookie(sKey) {
if (!sKey) { return null; }
@zhongdeliu
zhongdeliu / mersenne-twister.js
Created July 12, 2016 07:56 — forked from banksean/mersenne-twister.js
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
<?php
require 'vendor/autoload.php';
use Goutte\Client;
use GuzzleHttp\Client as GuzzleClient;
$client = new Client();
$guzzleClient = new GuzzleClient(array(
'verify' => false,
));
$client->setClient($guzzleClient);
@zhongdeliu
zhongdeliu / gist:93a8fc1d0b74fbaa22d8
Last active September 10, 2015 12:12
Global NPM modules
grunt-cli
karma-cli
gulp-cli
yo
bower
http-server