Skip to content

Instantly share code, notes, and snippets.

View arieljannai's full-sized avatar

Ariel Jannai arieljannai

View GitHub Profile
grep -r -I ":8443" . --exclude="*.log" --exclude="*.csv" --exclude-dir=".git" --exclude-dir="node_modules"
find . -type f -not \( -name "*.log" -o -name "*.csv" -o -name "*.png" -o -name "*.jpg" -o -name "*.gif" -o -path "*/.git/*" -o -path "*/node_modules/*" -prune \) -exec grep -n ':8443' {} /dev/null \;
@arieljannai
arieljannai / loop-all-tables.sql
Created September 7, 2016 14:25
Loop all tables for something
DROP PROCEDURE IF EXISTS loopTables;
DELIMITER //
CREATE PROCEDURE `loopTables` ()
BEGIN
DECLARE curr_table VARCHAR(200);
DECLARE cursor_tables CURSOR FOR select table_name from information_schema.tables where table_schema = (SELECT DATABASE());
OPEN cursor_tables;
grant_loop: LOOP
FETCH cursor_tables INTO curr_table;
-- do something
@arieljannai
arieljannai / cmder-context-menu.reg
Created July 7, 2016 08:31
Add Cmder to context menu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\directory\background\shell\Cmder\command]
@="\"c:\\tools\\cmder\\Cmder.exe\" \"%V\""
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\directory\background\shell\Cmder]
@="Cmder Here"
"NoWorkingDirectory"=""
"Icon"="C:\\tools\\cmder\\Cmder.exe"
@arieljannai
arieljannai / jasmine-matcher-toHaveEqualContent.js
Last active June 23, 2016 10:20
Jasmine matcher 'toHaveEqualContent' - expect two files to have the same content
var fs = require('fs');
var fsp = {
stat: function(file) {
return new Promise(function(resolve, reject) {
fs.stat(file, function(err, stats) {
if (err) return reject(err);
return resolve(stats);
});
});
@arieljannai
arieljannai / delete-java.ps1
Created June 17, 2016 06:25
Delete all java versions by oracle
# It's pretty slow, but works
Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match "Java" -and $_.Vendor -match "Oracle" } | ForEach-Object { $_.Uninstall() }
@arieljannai
arieljannai / 1-git-show-remotes-recursive.sh
Last active September 12, 2016 13:53
Remove port from git remote origin
find . -maxdepth 5 -name .git -type d | xargs -i bash -c 'p={}; echo ${p:0:-5}; git -C "{}" remote get-url origin; echo ""'
@arieljannai
arieljannai / users-with-unmatch-email.ps1
Last active June 8, 2016 05:53
Find users where their email does not match their usernames
# Unmatch
Get-ADUser -filter * -Properties SamAccountName, DisplayName, EmailAddress | select SamAccountName, DisplayName, EmailAddress | Where-Object {-not ($_.EmailAddress -like $_.SamAccountName + 'REPLACE_WITH_@COMPANY.COM')}
# Match
Get-ADUser -filter * -Properties SamAccountName, DisplayName, EmailAddress | select SamAccountName, DisplayName, EmailAddress | Where-Object {$_.EmailAddress -like $_.SamAccountName + 'REPLACE_WITH_@COMPANY.COM'}
for branch in $(git rev-list --all)
do
if (git ls-tree -r --name-only $branch | grep --quiet "FireFox")
then
echo $branch $(git branch --contains $branch)
fi
done
@arieljannai
arieljannai / moduleBaseDir.js
Created May 22, 2016 14:29
Get the base directory of your node module (no matter how deep it is)
var p = require('path');
var f = __dirname.substring(0, __dirname.lastIndexOf('node_modules') + 'node_modules'.length + p.sep.length);
var l = p.relative(f, __dirname);
console.log(l.split(p.sep)[0]);
@arieljannai
arieljannai / bitbucket_change_group_name.sql
Created April 18, 2016 11:10
Change BitBucket group name
update cwd_group set group_name='<new_group_name>', lower_group_name='<new_group_name>' where lower_group_name='<old_group_name>';
update cwd_membership set parent_name='<new_group_name>', lower_parent_name='<new_group_name>' where lower_parent_name='<old_group_name>';
update sta_project_permission set group_name='<new_group_name>' where group_name='<old_group_name>';
update sta_repo_permission set group_name='<new_group_name>' where group_name='<old_group_name>';