Skip to content

Instantly share code, notes, and snippets.

@vsviridov
vsviridov / ef4_pk_detect.cs
Created August 2, 2012 22:01
Crappy way to detect Primary Keys in EF4
//Get all fields marked as Primary Key
var keyFields = type.GetProperties()
.Where(prop => prop.GetCustomAttributes(typeof(KeyAttribute), true).Any())
.Select(prop => prop.Name)
.ToList();
//Get all fields that end with Id and Not marked as Foreign Key
keyFields.AddRange(type.GetProperties()
.Where(prop =>
prop.Name.EndsWith("Id", true, CultureInfo.InvariantCulture)
&& !prop.GetCustomAttributes(typeof(ForeignKeyAttribute), true).Any()
%!TEX TS-program = xelatex
\documentclass[24pt]{letter}
\usepackage{xeCJK}
\usepackage{ruby}
\setCJKmainfont{Hiragino Kaku Gothic ProN}
\usepackage{setspace}
%\doublespace
%
@vsviridov
vsviridov / AngularTimings.js
Created December 5, 2013 20:02
This is some assorted code to add support for Chrome Canary timline API to track angular timings. It also outputs some timings to the console.
(function(console)
{
"use strict";
var nop = function() {};
var ops = ["log", "info", "error", "warn", "time", "timeEnd", "group", "groupEnd", "timeline", "timelineEnd", "timeStamp"];
for(var x = 0; x < ops.length; x++)
{
if(!console[ops[x]]) { console[ops[x]] = nop; }
}
}(window.console = window.console || { $replaced: true }));
@vsviridov
vsviridov / NewEggBTC.user.js
Created December 21, 2014 01:53
GreaseMonkey script to see the BTC price before checkout.
// ==UserScript==
// @name NewEgg Price in Bitcoin
// @namespace gist.github.com/vsviridov/
// @description Display the grand total of your shopping cart in BTC
// @include *//secure.newegg.ca/Shopping/ShoppingCart.aspx*
// @include *//secure.newegg.com/Shopping/ShoppingCart.aspx*
// @version 1
// @grant none
// ==/UserScript==
@vsviridov
vsviridov / 01_add_cors.config.yaml
Created September 5, 2015 05:45
Add CORS to Nginx on AWS Elastic Beanstalk
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@vsviridov
vsviridov / brand.ts
Created September 30, 2023 07:37
sqlite to @typed-query-builder code generator
export type Brand<K, T> = K & { __brand: T };