Skip to content

Instantly share code, notes, and snippets.

View bkono's full-sized avatar

Bryan Konowitz bkono

View GitHub Profile
#!/usr/bin/ruby
if ENV['GIT_DIR'] == '.'
Dir.chdir('..')
ENV['GIT_DIR'] = '.git'
end
old_head, new_head, ref = STDIN.gets.split
puts ref
`echo \"#{ ref }\" >> head.txt`
if ref == "refs/heads/prod"
// jQuery to scroll to a target element
var x = $(ELEMENT).offset().top - 100;
$('html,body').animate({scrollTop: x}, 500);
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
var token =
BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes(Guid.NewGuid().ToString())))
.Replace("-", "").Substring(8, 12).ToLower();
server {
listen 80;
server_name www.mysite.com mysite.com;
rewrite ^/(.*) http://iwalkthevine.com permanent;
}
--'First Day of Last Month, and Last Day of Last Month'
declare @MyDate smalldatetime
set @MyDate = DATEADD(Month, -1, GETDATE())
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101)
set @MyDate = GETDATE()
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101)
@bkono
bkono / mash.chirp.config
Created August 9, 2011 04:43
mash.chirp.config -- Default Application and Vendor files
<?xml version="1.0"?>
<root
xmlns="urn:ChirpyConfig"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ChirpyConfig chirp.xsd">
<FileGroup Name="public/css/application.css" Minify="false">
<Folder Pattern="assets/css/*.min.css" />
</FileGroup>
@bkono
bkono / callrestservice.cs
Created August 13, 2011 06:07
Call a JSON Rest Service from c# with Newtonsoft.Json
private dynamic CallRestService(string uri, string method, dynamic parms) {
dynamic result;
var req = HttpWebRequest.Create(uri);
req.Method = method;
req.ContentType = "application/json";
byte[] bytes = UTF8Encoding.UTF8.GetBytes(parms.ToString());
req.ContentLength = bytes.Length;
using (var stream = req.GetRequestStream()) {
@bkono
bkono / spin-js-example.html
Created August 21, 2011 19:27
spin.js example
<!doctype html>
<head>
<title>Hi</title>
<style>
#spin {
background: #333;
color: white;
float: left;
width: 200px;
height: 200px;
@bkono
bkono / gist:1232401
Created September 21, 2011 15:36
Eager js validation with asp.net mvc 3
<script type="text/javascript">
$(document).ready(function () {
var settngs = $.data($('form')[0], 'validator').settings;
settngs.onfocusout = function (element) { $(element).valid(); };
});
</script>
options: { // options structure passed to jQuery Validate's validate() method
errorClass: "input-validation-error",
errorElement: "span",