Skip to content

Instantly share code, notes, and snippets.

View SergXIIIth's full-sized avatar

Sergey Makridenkov SergXIIIth

View GitHub Profile
@SergXIIIth
SergXIIIth / gist:862391
Created March 9, 2011 15:27
js help functions
window.log = (obj) -> if window.console then window.console.log(obj)
// usage
// var x = 42;
// var map = function (x) { return eval(x); };
// alert(f("x $x", map));
window.f = function (s, map) {
return s.replace(/\$(\w+)/g, function (dummy, v) { return map(v);} );
};
@SergXIIIth
SergXIIIth / gist:862396
Created March 9, 2011 15:32
live search
search = () ->
textboxs = $(".live_filter").add $("[data-live-cnt]")
textboxs.keyup ->
textbox = $(this)
cnt = textbox.attr("data-live-cnt")
cnt = "" unless cnt?
pattern = $.trim textbox.val()
/**
* jQuery.fn.sortElements
* --------------
* @author James Padolsey (http://james.padolsey.com)
* @version 0.11
* @updated 18-MAR-2010
* --------------
* @param Function comparator:
* Exactly the same behaviour as [1,2,3].sort(comparator)
*
@SergXIIIth
SergXIIIth / gist:882923
Created March 23, 2011 10:37
c# cool string extend
public static class StringExtentions
{
// example "Controls_Admin_AdminDocument_EditDocumentList load IsPostBack={0}".debug(IsPostBack);
public static void debug(this string str, params object[] args)
{
var args_json = args.Select(a => a.json()).ToArray();
Console.WriteLine("********************************");
Console.WriteLine(str.f(args_json));
Console.WriteLine("********************************");
@SergXIIIth
SergXIIIth / AspMvcViewToString.cs
Created March 23, 2011 14:32
asp mvc view to string
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web;
using System.IO;
namespace Msa.Common
@SergXIIIth
SergXIIIth / gist:1004230
Created June 2, 2011 10:39
Mongo gridfg upload test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using MongoDB.Driver;
using System.Web.Mvc;
using System.IO;
using MongoDB.Driver.GridFS;
@SergXIIIth
SergXIIIth / Curl.cs
Created August 5, 2011 09:29
c# curl or rest client
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Text;
using System.IO;
namespace Website.Model
{
def iis
path = File.absolute_path "website"
path = path.gsub('/', '\\')
sh "\"c:/Program Files (x86)/IIS Express/iisexpress\" /path:#{path} /port:9090"
end
def build
cd ".."
sln = FileList["*.sln"][0]
sh "c:/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe #{sln}"
@SergXIIIth
SergXIIIth / google_map.js
Created September 12, 2011 14:09
shops on google map with filter them by country
log = function(mes){
if (console){
console.log(mes);
}
}
jQuery.fn.rank = function(min, max) {
var result = $.grep(this, function(shop){
return min <= shop.rank && shop.rank <= max
});
@SergXIIIth
SergXIIIth / gist:1628715
Created January 17, 2012 20:31
The first Arduino HTTP request
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAB, 0xCB, 0xCD, 0xDE, 0x02 };
IPAddress ip(192,168,0,140);
IPAddress server(173,194,70,103);
EthernetClient client;