Skip to content

Instantly share code, notes, and snippets.

View yicone's full-sized avatar

yicone

View GitHub Profile
@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@ChrisCinelli
ChrisCinelli / gist:2051841
Created March 16, 2012 18:57
Logging of Javascript error on the Frontend to the Backend
/* ==========================================================
*
* Log on a remote server most of the errors in the browser
*
* @author Chris Cinelli
*
* Depends on:
* stacktrace.js - https://github.com/eriwen/javascript-stacktrace
* jsonStringify.js - http://www.thomasfrank.se/json_stringify_revisited.html
*
@davidmatas
davidmatas / mou.html
Last active March 1, 2023 16:42
highlight syntax for Mou.app
<!-- Highlight syntax for Mou.app, insert at the bottom of the markdown document -->
<script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script>
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/github.min.css">
<script>
hljs.initHighlightingOnLoad();
</script>
@yicone
yicone / gist:5105180
Last active December 14, 2015 15:08
从集合里取出来的,还是原来的引用吗
void Main()
{
// 初始化一个context
var cxt = new Context();
cxt.StepModel1 = new StepModel1{ Name = "foo1" };
cxt.StepModel2 = new StepModel2{ Name = "foo2" };
// 从context一个方法的内部的集合中取出一个model
var model1 = cxt.GetStepModel(1);
// 试着更新它
@yicone
yicone / gist:5149927
Created March 13, 2013 07:14
@vwxyzh EF里遇到一个诡异的问题:某表增加了一个字段A(类型为short?),更新了Entity, 程序中第一次使用该Entity的地方,是IQueryable<entity>.Min(r => r.B),当程序连接到另一台未添加字段的数据库,运行时并没有认为表结构有差异,而是返回这么一个异常: Min "The cast to value type 'Int16' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type."
// 修改前报异常。Entity中缺少新增的字段A,但是返回的异常是一个类型转换相关的
short minSecId = queryNoCached.Min(prc => prc.CacheHour);
// 修改后, 运行时容忍了Entity中缺少了新增的字段
short minSecId = queryNoCached.Min(prc => (short?)prc.CacheHour) ?? 0;
D/CordovaActivity(18223): onMessage(onPageStarted,file:///#!/sites)
D/CordovaLog(18223): file:///#!/sites: Line 1 : Uncaught ReferenceError: start is not defined
D/CordovaLog(18223): file:///#!/sites: Line 2 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 3 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 4 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 5 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 6 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 7 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 8 : Uncaught ReferenceError: addRow is not defined
D/CordovaLog(18223): file:///#!/sites: Line 9 : Uncaught ReferenceError: addRow is not defined
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@mbbx6spp
mbbx6spp / README.md
Last active October 22, 2024 13:13
Gerrit vs Github for code review and codebase management

Gerrit vs Github: for code review and codebase management

Sure, Github wins on the UI. Hands down. But, despite my initial annoyance with Gerrit when I first started using it almost a year ago, I am now a convert. Fully. Let me tell you why.

Note: This is an opinionated (on purpose) piece. I assume your preferences are like mine on certain ideas, such as:

  • Fast-forward submits to the target branch are better than allowing merge commits to the target branch. The reason I personally prefer this is that, even if a non-conflicting merge to the target branch is possible, the fact that the review/pull request is not up to date with the latest on the target branch means feature branch test suite runs in the CI pipeline reporting on the review/PR may not be accurate. Another minor point is that forced merge commits are annoying as fuck (opinion) and clutter up Git log histories unnecessarily and I prefer clean histories.
  • Atomic/related changes all in one commit is something worth striving for. Having your dev
@bjorgvino
bjorgvino / yosemite ntfs read+write.txt
Last active December 2, 2021 03:58
osxfuse + ntfs-3g + Yosemite = NTFS R/W
Remove osxfuse if installed via homebrew:
> brew uninstall osxfuse
Install osxfuse binary and choose to install the MacFUSE compatibility layer:
http://sourceforge.net/projects/osxfuse/files/latest/download?source=files
Reboot (optional but recommended by osxfuse)
Install ntfs-3g via homebrew:
> brew update && brew install ntfs-3g
@thbkrkr
thbkrkr / mongoexport-all-collections-as-json.sh
Created April 16, 2015 21:17
Export all MongoDB collections to JSON
#!/bin/bash
DB=$1
COLLECTIONS=$(mongo localhost:27017/$DB --quiet --eval "db.getCollectionNames()" | sed 's/,/ /g')
for collection in $COLLECTIONS; do
echo "Exporting $DB/$collection ..."
mongoexport -d newtickettoolDB -c $collection -o $collection.json
done