Skip to content

Instantly share code, notes, and snippets.

View Ivanca's full-sized avatar
💭
Why does github has statuses? Microsoft what the hell is wrong with you?🤦‍♂️

Ivan Ivanca

💭
Why does github has statuses? Microsoft what the hell is wrong with you?🤦‍♂️
View GitHub Profile
@Ivanca
Ivanca / gist:0449d625a158ceec6212
Last active August 29, 2015 14:04
Duplicate Selected GameObject To all Scenes (For Unity3D) [New Option In Transform inspector Menu]
using UnityEditor;
using UnityEngine;
using System.Collections;
public class DuplicateToAllScenesMenu : MonoBehaviour {
// Add a menu item called "Double Mass" to a Rigidbody's context menu.
[MenuItem ("CONTEXT/Transform/DuplicateToAllScenes")]
static void DuplicatePlz (MenuCommand command) {
EditorApplication.SaveCurrentSceneIfUserWantsTo ();
var matrix = [
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0]
];
var matrix = [
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0]
];
@Ivanca
Ivanca / scrapehn.js
Last active November 3, 2015 01:16
You would have to use this with a cronjob or something of the sort
var casper = require('casper').create({viewportSize: {width: 960, height: 600}});
var fs = require('fs');
casper.start('https://news.ycombinator.com/', function() {
var now = this.fetchText('#hnmain');
var old = fs.read('old.txt');
if (old !== now) {
casper.open('http://text-compare.com/', {
method: 'post',
data: {'text1': old, 'text2': now}
@Ivanca
Ivanca / New_Bind.js
Created December 16, 2012 04:47
Bind that can be override with other arguments; can be used with call and apply too (mixcall & mixapply)
// New methods for all functions: mixapply, mixcall, and mixbind
// Allows you to force arguments and context even after using .bind
// To skip any argument you can use NULL
// License: Public Domain
(function () {
var __bind = Function.prototype.bind;
var toArray = function (a) {
return Array.prototype.slice.call(a);
};
@Ivanca
Ivanca / IE_detection.js
Created December 17, 2012 00:36
Get Internet Explorer version; or return undefined if it is NOT internet explorer. Modded from james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/ Unfortunately IE10 doesn't accept HTML conditional statements, so we have to use a JS conditional statement.
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
do {
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->';
} while(all[0]);
var url = document.location.href;
var cdnFallback = /\bcdn=2/.test(url);
setTimeout(function(){
if( !window.jQuery && !cdnFallback )
document.location += (/\?/.test(url) ? "&" : "?") + "cdn=2";
},400);
if( cdnFallback ){
document.write('<script src="js/jquery-1.8.3.min.js"></scr'+'ipt>');
/**************
* Con promesas
**************/
var promise = foo().then(function(){
var promise = new Promise();
asyncFunction(function(){
// It has to know there is no need to merge it to a received object in order to
// do this;
var data = {key1:0x111};
@Ivanca
Ivanca / gist:4781307
Last active December 12, 2015 13:58
(function () {
var addMethod = function (obj, name, fn) {
obj[name] = function () {
var undef;
var result = fn.apply(obj, arguments);
if (result === undef) {
result = this;
}
return result;
@Ivanca
Ivanca / downs.sublime-macro
Last active December 13, 2015 21:39
The keys are need to be added to your `.sublime-keymap` file (Preferences > Key Bindings - User) [in the array]. Remember to remove the start & end brackets if needed. All the other files (the macros) need to go in the Packages\User directory. The files that have an "_e" at the end are the macros used to expand (eg. when selection is *not* empty)
[
{
"args":
{
"extend": false,
"to": "bol"
},
"command": "move_to"
},
{