Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block monyskynet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View guid_generator
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
View create_custom_datatemplate
[C#]Open in popup windowpublic class MyTemplate : ITemplate
public void InstantiateIn(Control container)
HyperLink link = new HyperLink();
link.Text = DataBinder.Eval(container, "DataItem.Id").ToString();
link.NavigateUrl = "javascript:alert('" + DataBinder.Eval(container, "DataItem.Id").ToString() + "');";
View create_date_template_programmatically
[C#]Open in popup windowpublic class MyTemplate : ITemplate
public void InstantiateIn(Control container)
HtmlAnchor control = new HtmlAnchor();
control.Name = "Hyper1";
control.Attributes.Add("onclick", "alert('dd')");
View copy record from one store to a new store
var records = []; store.each(function(r){ records.push(r.copy()); }); var store2 = new{ recordType: store.recordType }); store2.add(records);
monyskynet / register-javascript-in-a-page
Created Aug 20, 2013
Register JavaScript in a page
View register-javascript-in-a-page
// Define the name and type of the client script on the page.
String csName = "ButtonClickScript";
Type csType = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(csType, csName))
View Get url Queries
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
View random item in list
public static class EnumerableExtension
public static T PickRandom<T>(this IEnumerable<T> source)
return source.PickRandom(1).Single();
public static IEnumerable<T> PickRandom<T>(this IEnumerable<T> source, int count)
return source.Shuffle().Take(count);
View waitany and wait for others
List<Task<bool>> tasks = servers.Select(s => Task<bool>.Factory.StartNew(server => CallServer((string)server), s)).ToList();
bool result;
do {
int idx = Task.WaitAny(tasks.ToArray());
result = tasks[idx].Result;
} while (!result && tasks.Count > 0);
// cancel other tasks
monyskynet / new_gist_file
Created Jul 26, 2013
[jQuery] Get current version
View inject-jquery-to-page
var b=document.body;if(b){void(z=document.createElement('script'));void(z.type='text/javascript');void(z.src='');void(b.appendChild(z));}else{}
You can’t perform that action at this time.