Skip to content

Instantly share code, notes, and snippets.

#test markdown

this is a test of gist

angular.module('cbj', [])
.provider('singletonProvider', function() {
console.log('provider created');
this.$get = function () {
console.log('provider $get called');
return {provider: 1};
};
})
.factory('singletonFactory', function() {
console.log('factory created');

javascript中尾递归例子,可在chrome console中运行

fibonacci

var table = [1,1];
function f(n) {
  if(n < table.length) {
    return table[n];
  }
  table[n] = f(n-1) + f(n-2);

introduce arguments as array like object.

(() => {
  try {
    throw arguments.map(x => x * 3);
  } catch (e) {
    console.log(e);
  }
})(1, 2, 3)
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MsSql2012Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="C:\Users\twer\Documents\Visual Studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\Database1.mdf";Integrated Security=True</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
function Defer() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = this.reject;
});
}
var promises = [];
var pipelineName = 'XXXXXXXX';//replace
for(let i = 0; i < 100; i+=10){
@chenbojian
chenbojian / use-factory-girl.rb
Last active March 13, 2016 08:12
learn ruby
require 'factory_girl'
require 'securerandom'
FactoryGirl.define do
factory :user do
haha SecureRandom.hex(10)
hehe 88
end
end
@chenbojian
chenbojian / AsyncHelper.cs
Created March 12, 2019 03:12
AsyncHelper
// https://github.com/aspnet/AspNetIdentity/blob/master/src/Microsoft.AspNet.Identity.Core/AsyncHelper.cs
// Copyright (c) Microsoft Corporation, Inc. All rights reserved.
// Licensed under the MIT License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.chenbojian.jupyter</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/jupyter</string>
<string>notebook</string>