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:5243025
Last active December 15, 2015 10:08
Hacker news mobile
<style>
@media all and (max-device-width:760px) {
.pagetop b {
display:block;
}
.pagetop {
padding-top: 10px;
padding-bottom: 10px;
@Ivanca
Ivanca / Webflow.js
Last active December 22, 2015 21:09
(function ($) {
var dragging = null;
$(".style-editor").on("mousedown.wf", ".tick", function (e) {
var $ghost = $("<div class='drag-ghost'>").appendTo('body').css(
'cursor', 'ns-resize'
);
var $input = $(this).closest('.input-control').find('input');
dragging = {
@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 / gist:79d3daa0328f0546298c
Created December 9, 2014 06:45
Collapse Diffs - Functionality for Github commits (UserScript/Tampermonkey/Greasemonkey)
// ==UserScript==
// @name Collapse diff
// @namespace http://no.one/
// @version 0.2
// @description Enter something useful
// @author You
// @match https://github.com/*
// @grant none
// ==/UserScript==
@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 / sorty by frequency.js
Last active August 1, 2017 20:52
Most common words (excluding
function sortByFrequency(array) {
var frequency = {};
array.forEach(function(value) { frequency[value] = 0; });
var uniques = array.filter(function(value) {
return ++frequency[value] == 1;
});
return uniques.sort(function(a, b) {
return frequency[b] - frequency[a];
// Flattens an array, e.g. [[1,2,[[[3]]]],4] => [1, 2, 3, 4]
var flattenArray = (array) => {
let initialValue = [];
return array.reduce((result, ele) => {
if (Array.isArray(ele)) {
let flat = flattenArray(ele);
return result.concat(flat);
} else {
result.push(ele);
return result;
(function ajaxLoadNextPage () {
var more = document.querySelector('.comment-tree > tbody > tr:last-child a');
if (more && more.innerHTML === "More") {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
more.remove();
var div = document.createElement('div');
div.innerHTML = httpRequest.responseText;