Skip to content

Instantly share code, notes, and snippets.

View lloydzhou's full-sized avatar
:octocat:
Focusing

Lloyd Zhou lloydzhou

:octocat:
Focusing
View GitHub Profile
@lloydzhou
lloydzhou / nginx.conf
Last active April 25, 2022 06:02
nginx srcache module to server stale data, using lua-resty-lock to make one request to create new cache, and using "lua-resty-http" + "ngx.timer.at" to update new cache in background.
upstream www {
server 127.0.0.1:9999;
}
upstream redis {
server 127.0.0.1:6379;
keepalive 1024;
}
lua_shared_dict srcache_locks 100k;
server {
#!/usr/bin/env python
# coding=utf-8
import bs4
import tornado.ioloop
import tornado.options
from tornado.httpclient import AsyncHTTPClient
from adesk.db import ipai_mongo
import datetime
import os
@lloydzhou
lloydzhou / magento-cli.py
Created December 17, 2015 15:09 — forked from nyov/magento-cli.py
A Magento REST API example with rauth as OAuth provider.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from rauth.service import OAuth1Service
# Create consumer key & secret in your Magento Admin interface
# For an API Guideline see:
# http://www.magentocommerce.com/api/rest/authentication/oauth_authentication.html
#
# Short Magento setup explanation:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>订餐计算器</title>
<!-- Bootstrap -->
<app>
<home class="app-page" data-page="true"></home>
<detail class="app-page" data-page="true"></detail>
<cart class="app-page" data-page="true"></cart>
<checkout class="app-page" data-page="true"></checkout>
var path = location.pathname.split('/')
var collections = ['home', 'detail', 'cart', 'checkout']
, pages = {}, activeClass = 'app-active'
, currentCollection = path.length > 2 && path[2] ? path[2] : 'home'
<?php
$template = tplite();
$callback = function($s){print $s;};
$template(file_get_contents('test.tpl'), [
'title'=>'test title',
'messages' => ['test message1', 'test messages2']
], $callback);
?>
@lloydzhou
lloydzhou / t.php
Created January 14, 2016 10:10
template
<?php
function t($t,$d='data'){return "extract(\$$d);".str_replace(['{{','}}','{%','%}'],['");$c(',');$c("','");','$c("'],'%}'.$t.'{%');}
// demo
$data = [
'title' => 'test title',
'messages' => ['message1', 'message2', 'message3']
];
$c='print_r';
<?php
function logger($path = 'php.log', $cond = true) {
$logs = array();
register_shutdown_function(function() use ($path, &$logs){
return count($logs) > 0 ? @file_put_contents($path, implode(array_map(function($log){
return count($log) > 1 ? call_user_func_array('sprintf', $log) : current($log);
@lloydzhou
lloydzhou / LICENSE.txt
Created May 16, 2016 09:54 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@lloydzhou
lloydzhou / get-old-chromium-binary.md
Created July 12, 2017 09:38 — forked from cletusw/get-old-chromium-binary.md
Download an old Chromium binary

(source)

Taking [denilson-sá's answer][2] further...

You need revision numbers to grab downloads. So first lookup the full version string from the following URL, adjusting parameters as needed:

https://omahaproxy.appspot.com/history.json?channel=stable&os=mac

For Chrome version 28 the full version string is 28.0.1500.71. Now go to https://omahaproxy.appspot.com and enter the full version string ("28.0.1500.71") into the Position Lookup box. Copy the Base Position number ("209842" in this case).