Skip to content

Instantly share code, notes, and snippets.

using System.Collections.Generic;
using System.Text;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace TestHub
{
class Program
{
public static void Main(string[] args)
@sangcu
sangcu / app.js
Created July 13, 2017 00:52
Review - Monster -1
var score = 0
, initialMousePos, initialMonsterPos;
var lineTop = document.querySelector('#line-top');
var lineBottom = document.querySelector('#line-bottom');
var monster = document.querySelector('#monster');
monster.addEventListener('mousedown', function (evt) {
startGame(evt);
});
@sangcu
sangcu / sample_text.txt
Created January 3, 2017 12:53
Sample text
Chapter One A Stop on the Salt Route 1000 B.C. As they rounded a bend in the path that ran beside the river, Lara recognized the silhouette of a fig tree atop a nearby hill. The weather was hot and the days were long. The fig tree was in full leaf, but not yet bearing fruit. Soon Lara spotted other landmarks—an outcropping of limestone beside the path that had a silhouette like a man’s face, a marshy spot beside the river where the waterfowl were easily startled, a tall tree that looked like a man with his arms upraised. They were drawing near to the place where there was an island in the river. The island was a good spot to make camp. They would sleep on the island tonight. Lara had been back and forth along the river path many times in her short life. Her people had not created the path—it had always been there, like the river—but their deerskin-shod feet and the wooden wheels of their handcarts kept the path well worn. Lara’s people were salt traders, and their livelihood took them on a continual journey.
@sangcu
sangcu / letsencrypt.md
Created September 3, 2016 15:14 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.3/elasticsearch-2.3.3.tar.gz
tar -xvf elasticsearch-2.3.3.tar.gz
tar -xvf elasticsearch-2.3.3.tar.gz
@sangcu
sangcu / faye.rb
Last active August 29, 2015 14:26 — forked from tmcallister/faye.rb
Faye with nginx config
FAYE_TOKEN = 'secretToken'
if defined? Rails
if Rails.env == 'development'
FAYE_URI = "http://#{APP_CONFIG[:nameremoved_service][:host]}:9292/faye"
else
FAYE_URI = "https://#{APP_CONFIG[:nameremoved_service][:host]}/faye"
end
$(document).ready(function(){
$('#myButton').click(function(sender,e){
var _this = this;
var $this = $(this);
console.log(_this.find==undefined,$this.find==undefined);
console.log(_this.prev==undefined,$this.prev==undefined);
console.log(_this.next==undefined,$this.next==undefined);
console.log(_this.parent==undefined,$this.parent==undefined);
});
});
@sangcu
sangcu / authen_route
Created August 27, 2014 17:23
How to check authentication on incoming request
var _ = require('underscore');
var authenController = require('../controllers/authentication');
var config = require('../configs/config');
var constant = require('../configs/constant');
module.exports = {
authen:function(req, res, next){
var domain = req.customdomain;
var token = req.header("token");
if(!domain || !token){
res.send(401,{message:req.i18n.t("app.unauthentication")});
@sangcu
sangcu / sectionController
Created August 27, 2014 17:19
A piece of code on controller
var _ = require('underscore');
var Promise = require('es6-promise').Promise;
var lessonModel = require('../models/lesson');
var courseModel = require('../models/course');
var sectionModel = require('../models/section');
var gearmanJob = require('../gearman/clients/client');
function SectionController(){
}
SectionController.prototype.getAdminSections=function(ids){
@sangcu
sangcu / build_tool_grunfile
Created August 27, 2014 17:16
This is how I used build tool to develop the app
module.exports = function(grunt) {
grunt.initConfig({
htmlcompressor: {
compile: {
files: {
//'index.min.html': 'index.html',
'views/landing-min/landing.min.html': 'views/landing-default/landing.html',
'views/landing-min/main.min.js': 'views/landing-default/main.min.js'
},
options: {