Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html>
<head>
<title>Rich Text Editor</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
@jerry4
jerry4 / simpleCookies.js
Created December 12, 2014 21:31
Vanilla js to get cookies
// from stackoverflow: http://stackoverflow.com/questions/5639346/shortest-function-for-reading-a-cookie-in-javascript
(function(){
var cookies;
function readCookie(name,c,C,i){
if(cookies){ return cookies[name]; }
c = document.cookie.split('; ');
cookies = {};
@jerry4
jerry4 / index.html
Created December 5, 2014 04:17
AngularJS test // source http://jsbin.com/xayicawoka
<!doctype html>
<html ng-app="test" >
<head>
<meta charset="utf-8">
<title>AngularJS test</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular-route.js"></script>
</head>
<body>
@jerry4
jerry4 / AnonymousTypeToClass.cs
Created November 22, 2014 23:09
create fields from anonymous type
// resharper has a refactoring for this but I use it in LinqPad. This works for very simple cases to save me some typing
foreach(var prop in anon.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
{
Console.WriteLine("\tpublic {0} {1};", prop.PropertyType, prop.Name);
}
@jerry4
jerry4 / ng-helpers.js
Last active August 29, 2015 14:09
ng app debugging
if (jerry) { alert("already added ngHelpers"); } //
var jerry = (function(){
var count = 0;
var unregisterDigestWatch = function() {}; // init empty
function registerDigestWatch(scope) {
scope = scope || angular.element(document).scope();
unregisterDigestWatch = scope.$watch(function() {
var c = count++;
@jerry4
jerry4 / get-watchers.js
Last active August 29, 2015 14:09 — forked from kentcdodds/get-watchers.js
angular: get the watch count for a page
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
/*
@jerry4
jerry4 / 24 hour cultures
Last active January 2, 2016 03:29
What cultures use 24 hour time? (example limits to english cultures) from stack overflow answer...
void Main()
{
var cultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures);
foreach(var cultureInfo in cultures)
{
Thread.CurrentThread.CurrentCulture = cultureInfo;
var datetime = new DateTime(2000, 1, 1, 23, 0, 0);
var formatted = datetime.ToString("t");
var is24Hrs = formatted.Contains("23");
//Assert.AreEqual(is24Hrs, cultureInfo.Is24Hrs());