Skip to content

Instantly share code, notes, and snippets.

Daniel Cohen Gindi danielgindi

Block or report user

Report or block danielgindi

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
@danielgindi
danielgindi / delete_bitbucket_lfs_files.js
Created Aug 19, 2019
Bulk delete Bitbucket LFS files
View delete_bitbucket_lfs_files.js
// Run this in Chrome's console, while in Bitbucket's website and logged in
const csrftoken = document.cookie.match(/\bcsrftoken=(.*?)(?:;| |$)/)[1];
const repoName = 'your_account/your_repo_name';
const expiry = 1000 * 60 * 60; // Delete only files older than an hour
let page = 1;
function iterateNext() {
fetch(`https://bitbucket.org/${repoName}/admin/lfs/file-management/?page=${page}`, {
method: 'GET',
@danielgindi
danielgindi / node_v11.x_sourceless_script.patch
Last active Mar 25, 2019
Patch to add a "sourceless" feature to node.js v11.x
View node_v11.x_sourceless_script.patch
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -1564,9 +1564,10 @@ class V8_EXPORT ScriptCompiler {
};
enum CompileOptions {
- kNoCompileOptions = 0,
- kConsumeCodeCache,
- kEagerCompile
+ kNoCompileOptions = 0x00,
@danielgindi
danielgindi / node_v10.x_sourceless_script.patch
Last active Mar 25, 2019
Patch to add a "sourceless" feature to node.js v10.x
View node_v10.x_sourceless_script.patch
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -1449,12 +1449,13 @@ class V8_EXPORT ScriptCompiler {
enum CompileOptions {
kNoCompileOptions = 0,
- kProduceParserCache,
- kConsumeParserCache,
- kProduceCodeCache,
- kProduceFullCodeCache,
@danielgindi
danielgindi / callout-view.js
Created Nov 1, 2018
Callout view for React Native
View callout-view.js
import React, { Component } from 'react';
import { View, StyleSheet, Text, Image } from 'react-native';
import PropTypes from 'prop-types';
import { TouchableNativeFeedback } from 'react-native';
export default class CalloutView extends Component {
static propTypes = {
onPress: PropTypes.func,
parentLayout: PropTypes.any,
@danielgindi
danielgindi / get_lowest_ip_ranges.js
Created Nov 21, 2017
Generate a list of the common-denominator CIDR IP ranges from a list of IPs
View get_lowest_ip_ranges.js
function getLowestIpRanges(ips) {
let ipRanges = [];
ips.forEach(x => {
let x3 = x.replace(/\d+$/, '');
let x2 = x3.replace(/\d+\.?$/, '');
let x1 = x2.replace(/\d+\.?$/, '');
let ex = ipRanges.filter(y => y == x3 + '0' || y == x2 + '0.0' || y == x1 + '0.0.0');
if (ex.length) return;
@danielgindi
danielgindi / css_minifer.js
Last active Jul 12, 2017
CSS minifier (JS)
View css_minifer.js
var CssMinifier = (function () {
function unescapeString(value) {
// CSS RFC states that the escape character (\) escapes every character to itself,
// except for a variable length hex-digit sequence that is converted to a character by that hex value.
// An escaped hex value can be ended with an optional whitespace ( \t\n).
var out = '';
var quoted = false;
var hexEscapeSeq = '';
@danielgindi
danielgindi / mysql_rename_database.sql
Last active Mar 14, 2017
Rename database in Mysql
View mysql_rename_database.sql
SET SESSION group_concat_max_len = 99999999999;
SET @old_schema_name = 'old_schema';
SET @new_schema_name = 'new_schema';
SELECT GROUP_CONCAT(statement SEPARATOR '')
FROM (
SELECT 'DELIMITER $$\n\n' AS statement
UNION ALL
@danielgindi
danielgindi / get_distant_brightness_color.js
Created Nov 15, 2016
Find the color (out of an array of colors) that is most distant (brightness-wise) to the target color.
View get_distant_brightness_color.js
var getDistantBrightnessColor = (function () {
// Calculate grayscale color (luma) according to ITU-R Recommendation BT. 709
var grayscaleLuma709Color = function(color) {
return Math.round(0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b)
};
var linearDiffColor = function(color1, color2) {
return Math.abs(color1.r - color2.r) +
Math.abs(color1.g - color2.g) +
@danielgindi
danielgindi / exec_fun_w_args_isolated.js
Created Sep 18, 2016
JS: Execute function given name and args - in an isolate scope
View exec_fun_w_args_isolated.js
var execIsolated = (function () {
var exec = function () {
arguments[0](arguments[1]);
};
return function (funcname, args) {
args = args || [];
@danielgindi
danielgindi / syntax_convert.js
Last active Mar 6, 2017
Convert syntax between languages
View syntax_convert.js
/* Note:
This is not meant for translating real code between languages.
Only for basic syntax translation, to get you started with a skeleton,
before doing line-by-line manually
*/
var Converter = {
curlifyWhitespace: function (code) {
You can’t perform that action at this time.