Skip to content

Instantly share code, notes, and snippets.

View arieljannai's full-sized avatar

Ariel Jannai arieljannai

View GitHub Profile
@arieljannai
arieljannai / defaultLogger.js
Created March 27, 2016 10:18
default logger
var logger = function(event, log){
switch(event) {
case 'info':
break;
case 'log':
console.log(log);
break;
case 'warn':
console.warn(log);
break;
@arieljannai
arieljannai / start-programming.md
Last active April 17, 2016 11:13
Some resources for people who start programming (Groups, pages and websites that is nice to know when you start programming - Ask questions, contribute open source, be part of the community)
@arieljannai
arieljannai / webstorm.bat
Last active May 18, 2016 05:30
Adds WebStorm entries to context menu
@echo off
@rem throw this file in jetbrains installation folder, it takes the last created WebStorm folder (the latest ide update) for the script
FOR /F "delims=" %%i IN ('dir /b /ad-h /t:c /od -filter "WebStorm*"') DO SET a=%%i
SET WebStormPath=C:\Program Files (x86)\JetBrains\%a%\bin\WebStorm64.exe
echo %WebStormPath%
echo Adding file entries
@arieljannai
arieljannai / jwtToken.js
Created February 2, 2016 14:32
generates a JWT token
var jwt = require('jsonwebtoken');
module.exports = {
getJwtToken : function(issuer, secret) {
var issuedAt = Math.floor(Date.now() / 1000);
var payload = {
iss: issuer,
jti: Math.random().toString(),
iat: issuedAt,
exp: issuedAt + 60,
@arieljannai
arieljannai / wifi-set-on-off.bat
Last active January 31, 2016 13:37
Set the WiFi interface on or off
@rem save the script wherever you'd like to
@rem create a shortcut named "wifi" and put it in a place that's in your path (shortcuts folder, system32, whatever..)
@rem set the shortcut to run as administrator! IMPORTANT!
@rem run "wifi on" or "wifi off" and enjoy your life.
@rem the default wifi interface name is "Wireless Network Connection" just cause that's the way it's on my computer.
@rem you can run "wifi-set-on-off.bat" script without any parameters to see what's your wifi interface name (I've added "Wi" filter assuming it will be WiFi or wireles..)
@ECHO OFF
@arieljannai
arieljannai / users-with-password-expired.ps1
Created January 31, 2016 10:35
Get all the users that their password has been expired (expiry date is set to the epoch date 1/1/1601 2:00:00 AM)
Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties "SamAccountName", "DisplayName", "msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property "SamAccountName", "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | Where-Object {$_.ExpiryDate -like '*1601*'}
@arieljannai
arieljannai / curl-commands.sh
Created January 26, 2016 13:46
Mozilla add ons api
# the node app retrieves the jwt token
# result in: upload-amo-result.json
echo "curl https://addons.mozilla.org/api/v3/addons/{%%%ADDON_UUID%%%}/versions/%%%ADDON_VERSION%%%/ -XPUT --form 'upload=@C:/firefox-addon.xpi' -H 'Authorization: $(node index.js)'" | sh
# result in: status-amo-result.json
echo "curl https://addons.mozilla.org/api/v3/addons/%%%UPLOADER_MOZILLA_DEV_MAIL%%%/versions/%%%ADDON_VERSION%%%/uploads/%%%UPLOAD_PK%%%/ -H 'Authorization: $(node index.js)'" | sh
@arieljannai
arieljannai / mysql_sequence.sql
Last active February 6, 2023 06:01
creating sequence with nextval, currval, setval in mysql
-- based on http://www.microshell.com/database/mysql/emulating-nextval-function-to-get-sequence-in-mysql/
-- might be needed
-- SET GLOBAL log_bin_trust_function_creators = 1;
CREATE TABLE `sequence_data` (
`sequence_name` varchar(100) NOT NULL,
`sequence_increment` int(11) unsigned NOT NULL DEFAULT 1,
`sequence_min_value` int(11) unsigned NOT NULL DEFAULT 1,
`sequence_max_value` bigint(20) unsigned NOT NULL DEFAULT 18446744073709551615,
@arieljannai
arieljannai / private-chrome-store.reg
Last active January 18, 2016 13:28
To allow installing chrome extensions (crx) from sources other then chrome web store (private stores)
Windows Registry Editor Version 5.00
; To allow installing chrome extensions (crx) from sources other then chrome web store, add this registry to your computer
; And don't forget to change the urls to your private chrome store
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallSources]
"1"="http://webstore.mysite.com/ChromeExt/*"
"2"="http://another-source.mysite.com/ChromeExt/*"
// for this purpose we used the icon propery of our tree object to identify that it is a file (a folder doesn't have an icon, it uses the default one)
var customTreeSort = function(a, b) {
if (this.get_node(a).icon === 'jstree-file' && this.get_node(b).icon === 'jstree-file') {
// organize files
return this.get_text(a).localeCompare(this.get_text(b));
} else {
// files before folders
if (this.get_node(a).icon === 'jstree-file') {
return -1;