Skip to content

Instantly share code, notes, and snippets.

@sangcu
sangcu / Ember.Editable.js
Created August 8, 2012 17:01 — forked from pjlammertyn/Ember.Editable.js
Ember.Editable mixin
Ember.Editable = Ember.Mixin.create({
_originalPropertyStates: Ember.Map.create(),
_isEditing: false,
willDestroy: function () {
var $this = this;
for (var prop in this.getOwnProperties()) {
Ember.removeBeforeObserver($this, prop, $this, '_beforePropertyChange');
}
},
@sangcu
sangcu / create_custom_culture.cs
Last active March 1, 2021 15:21
Create a custom culture in C#. In this case, I created a custom culture for Euro Union then registered as a standard culture on window.
// This example demonstrates the System.Globalization.Culture-
// AndRegionInfoBuilder Register method.
// Compile this code example with a reference to sysglobl.dll.
// reference to MSDN for custom culture
using System;
using System.Globalization;
using System.Linq;
class Sample
{
public static void Main()
@sangcu
sangcu / routing_expressjs
Last active August 29, 2015 14:05
This is a piece of code that I have written to build routing for an RESTful API. (I used Expressjs)
module.exports={
items:[
{
url:'/api/v1/system/health',
method:'post',
handler:system.health
},
{
url:'/api/v1/system/ping',
method:'get',
@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: {
@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 / 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")});
$(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 / 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
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 / 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: