Skip to content

Instantly share code, notes, and snippets.

Stepan Suvorov stevermeister

Block or report user

Report or block stevermeister

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 gist:c2ec0c1768e1600b0d44
function goImage(){
html2canvas(document.getElementById('Stage_screen'), {
onrendered: function(canvas) {
window.open(canvas.toDataURL('image/jpeg'));
}
});
}
@stevermeister
stevermeister / downloadFile.js
Last active Aug 29, 2015
JavaScript File download imitation
View downloadFile.js
window.downloadFile = function(sUrl) {
 
    //If in Chrome or Safari - download via virtual link click
    if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
        //Creating new link node.
        var link = document.createElement('a');
        link.href = sUrl;
 
        if (link.download !== undefined){
            //Set HTML5 download attribute. This will prevent file from opening if supported.
View Git pre-push hook
#!/bin/node
var grunt = require('grunt');
(function () {
'use strict';
grunt.tasks(['test'], {}, function () {
console.log('pre push hook: SUCCESS');
process.exit(0);
});
@stevermeister
stevermeister / git pre-push hook
Created Mar 12, 2015
git pre-push hook to run tests
View git pre-push hook
#!/bin/sh
# check for how many uncommitted changes we have
# stash changes
# run grunt task
# restore stashed files if anything was stashed
# exit with error if grunt fails
NAME=$(git branch | grep '*' | sed 's/* //')
@stevermeister
stevermeister / ng-watch-visualisation
Created Mar 14, 2015
AngularJS watchers visualization
View ng-watch-visualisation
(function visualizeAngularWatchers() {
var i, data, scope,
count = 0,
all = document.all,
len = all.length,
test = {},
overlayMain = angular.element('<div/>');
overlayMain.css({'z-index': 9999});
angular.element(document.body).append(overlayMain);
@stevermeister
stevermeister / ui-router-logger.js
Created Apr 13, 2015
AngualrJS ui-router logger snippet (helps for debug)
View ui-router-logger.js
// Credits: Adam's answer in http://stackoverflow.com/a/20786262/69362
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeError - fired when an error occurs during transition.');
console.log(arguments);
@stevermeister
stevermeister / obect-c-javascript.js
Created May 16, 2015
Access Object-C properties in JavaScript example
View obect-c-javascript.js
ObjC.import("Cocoa");
var styleMask = $.NSTitledWindowMask | $.NSClosableWindowMask | $.NSMiniaturizableWindowMask;
var windowHeight = 350;
var windowWidth = 550;
var window = $.NSWindow.alloc.initWithContentRectStyleMaskBackingDefer( $.NSMakeRect(0, 0, windowWidth, windowHeight), styleMask, $.NSBackingStoreBuffered, false );
var label = $.NSTextField.alloc.initWithFrame($.NSMakeRect(25, (windowHeight - 40), 200, 24));
label.stringValue = "Label:";
label.drawsBackground = false;
label.editable = false;
@stevermeister
stevermeister / testFunc.js
Created Jun 7, 2015
Test function 600+ symbols perf
View testFunc.js
function large(a,b){
//lkfajsd;flkdsajflk;dsadklsjflk;dsajflk;dsadjflksdajfl;kadsjfkldsajflsda;fj
//asl;fjsadlkfjdsal;kfjads;klfjdsakldkl;afjdsakl;fjdls;akfjklsd;ksdjadfjls
//lkfajsd;flkdsajflk;dsadklsjflk;dsajflk;dsadjflksdajfl;kadsjfkldsajflsda;fj
//asl;fjsadlkfjdsal;kfjads;klfjdsakldkl;afjdsakl;fjdls;akfjklsd;ksdjadfjls
//lkfajsd;flkdsajflk;dsadklsjflk;dsajflk;dsadjflksdajfl;kadsjfkldsajflsda;fj
//asl;fjsadlkfjdsal;kfjads;klfjdsakldkl;afjdsakl;fjdls;akfjklsd;ksdjadfjls
//lkfajsd;flkdsajflk;dsadklsjflk;dsajflk;dsadjflksdajfl;kadsjfkldsajflsda;fj
View roulette.sh
#!/bin/sh
BANG="echo test"
while getopts :c OPT; do
case $OPT in
c|+c)
#Chicken mode engaged! Non-root execution allowed.
BANG="echo chicken!"
chicken=1
View gist:014339d4f8630c1537d3cdf4fcf30d13
describe('Calc', function() {
beforeEach(module('myApp'));
describe('service', function() {
it('should do sum', inject(function(Calc) {
expect(Calc.sum(3,4)).toBe(7);
}));
You can’t perform that action at this time.