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 / Amara Plus.js
Created March 14, 2013 17:33
Better control for Amara.org subtitle's editing (youtube subtitles creator and manager).
// ==UserScript==
// @name Amara Plus
// @namespace http://rapedinheaven.com
// @version 0.1
// @description enter something useful
// @match http://www.amara.org/es/onsite_widget/*
// @copyright 2012+, You
// ==/UserScript==
var getByClass = function (sel, parent) {
@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: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 / 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;
@Ivanca
Ivanca / to-php56.sh
Last active December 9, 2017 08:26
Upgrading from php5.3 to php5.6 on Amazon Linux AMI
#!/bin/bash
# Stop it all
sudo service httpd stop
sudo service php-fpm stop
# Remove problematic packages
sudo yum remove -y httpd httpd-tools apr apr-util
# Remove old php and php extensions
@Ivanca
Ivanca / Q-adverts.py
Last active February 23, 2018 02:54
Q adverts translated to python
# Each-prior
#####################################################################
# in Q >>>
types: type'[(1;2h;3.2)]
# returns the type of each element (-7 -5 -9h)
# in PYTHON >>>
numbers = [1, 2, 3.2]
types = list(map(type, numbers))
def hanoi(n, source, helper, target):
print "hanoi( ", n, source, helper, target, " called"
if n > 0:
# move tower of size n - 1 to helper:
hanoi(n - 1, source, target, helper)
# move disk from source peg to target peg
if source[0]:
disk = source[0].pop()
print "moving " + str(disk) + " from " + source[1] + " to " + target[1]
target[0].append(disk)