Skip to content

Instantly share code, notes, and snippets.

@gyoshev
gyoshev / Javascript-influence-over-csharp.aspx
Created April 6, 2010 11:45
Javascript-influence-over-csharp
<% for (var i = 0; i < 10; i++) {
Html.Telerik().ScriptRegistrar().OnDocumentReady(
(new Func<int, Action>((index) => {
return () => {
%> alert(<%= index %>); <%
};
}))(i));
} %>
@gyoshev
gyoshev / gist:1160202
Created August 21, 2011 05:45
qHint core function
function jsHintTest(name, sourceFile, options) {
function validateFile(source) {
var i, len, err,
result = JSHINT(source, options),
errors = JSHINT.errors;
ok(result);
if (result) {
return;
@gyoshev
gyoshev / gist:1779642
Created February 9, 2012 12:28
Kendo UI Demo mode (Overview example)
var countryInput = $("#country"),
ddl = countryInput.data("kendoDropDownList"),
itemsCount = ddl.dataSource.view().length;
setInterval(function() {
ddl.select(~~(Math.random() * itemsCount));
ddl.trigger("change");
}, 3000);
@gyoshev
gyoshev / heapsort.js
Created November 8, 2012 13:36
Heap sort in javascript
var a = [ 9, 10, 2, 1, 5, 4, 3, 6, 8, 7, 13 ];
function swap(a, i, j) {
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
function max_heapify(a, i, length) {
while (true) {
@gyoshev
gyoshev / polling-to-rewind
Last active December 17, 2015 09:49
Loop a Grooveshark song without fetching it from the server on each play
var rewindPoller = setInterval(function() {
var song = Grooveshark.getCurrentSongStatus().song;
if (song.position > song.calculatedDuration - 2000) {
Grooveshark.seekToPosition(0)
}
}, 1000);
// to stop the looping
clearInterval(rewindPoller);
@gyoshev
gyoshev / cookieclicker.js
Last active December 23, 2015 19:59
Automation for CookieClicker (http://orteil.dashnet.org/cookieclicker/)
// click the cookie
setInterval(function() {
$("#bigCookie").trigger("click")
}, 100);
// purchase upgrades and buildings
setInterval(function () {
$("#store .upgrade.enabled").trigger("click");
$(".product.enabled").last().trigger("click");
}, 1000);
@gyoshev
gyoshev / em-conversion-table.py
Created October 15, 2013 12:27
Output px2em conversion table
# default base is 14px (= 1em)
# outputs range from 1px to 30px
print('\n'.join([
str(x) + "px = " + str(round(x/14.0, 4)) + "em"
for x in range(1,30)
]))
@gyoshev
gyoshev / process.js
Created July 15, 2014 16:05
Convert SVG to Canvas JS code
#!/usr/bin/node
var canvg = require("canvg");
var Canvas = require("canvas");
fs = require('fs')
var svg_input;
var args = process.argv.slice(2);
@gyoshev
gyoshev / keybase.md
Last active September 19, 2017 13:24
keybase.md

Keybase proof

I hereby claim:

  • I am gyoshev on github.
  • I am gyoshev (https://keybase.io/gyoshev) on keybase.
  • I have a public key whose fingerprint is 87DD C2C5 9AC3 8703 5C07 BE2B CB26 A70F 5E59 5A4F

To claim this, I am signing this object:

@gyoshev
gyoshev / vue-microfrontends-sample.ts
Created July 1, 2020 08:15
Vue Microfrontends sample
// register a microfrontend module
shell.registerModule((router: DynamicRouter, container: InversifyContainer) => {
// dependencies
container.bind(IntegrationsApi).to(AxiosIntegrationsApi)
container.bind(IntegrationsMetrics).toSelf();
// routes and views
router.addChildRoutes([
{ path: 'partner-integrations', component: IntegrationsDashboard },
{ path: 'partner-integrations/mparticle', component: MParticleIntegrationPage },