Skip to content

Instantly share code, notes, and snippets.

@ygilad
ygilad / class.Diff.php
Created July 8, 2019 10:42
[PHP] A class containing a diff implementation
<?php
/*
class.Diff.php
A class containing a diff implementation
Created by Stephen Morley - http://stephenmorley.org/ - and released under the
terms of the CC0 1.0 Universal legal code:
@ygilad
ygilad / Cryptor.php
Created July 2, 2019 12:06 — forked from Radiergummi/Cryptor.php
A PHP class to encrypt and decrypt strings using a static application secret. Input is converted to hex strings to enable easier handling
<?php
namespace Vendor\Library;
use function bin2hex;
use function hex2bin;
use function openssl_decrypt;
use function openssl_encrypt;
/**
@ygilad
ygilad / clear_project_pycache.cmd
Created June 5, 2019 16:33
Multiplatform clearing of __pycache__ dirs in a project
# Note: Run from project root
# From: https://stackoverflow.com/a/41386937/1853298
python -c "import pathlib; [p.unlink() for p in pathlib.Path('.').rglob('*.py[co]')]"
python -c "import pathlib; [p.rmdir() for p in pathlib.Path('.').rglob('__pycache__')]"
@ygilad
ygilad / backup_svn.bat
Last active May 7, 2019 09:54
A script For scheduling hourly svn patches (svn diff) for multiple branches. Setup: modify full_svn_backup with your svn locations for backup and run schedule_svn_backup.bat to schedule an hourly backup.
@echo off
SET SVN_DIR=C:\webserver\SVN\QA\Automation\Master
SET FILE_PREFIX=QA
SET BU_DIR="C:\Users\yuval\OneDrive - Qmarkets\work backup\Auto"
IF NOT [%1] == [] (SET SVN_DIR=%1)
IF NOT [%2] == [] (SET FILE_PREFIX=%2)
IF NOT [%3] == [] (SET BU_DIR=%3)
set CUR_YYYY=%date:~10,4%
@ygilad
ygilad / new_chrome.py
Last active January 31, 2019 13:04
Runs Chrome on ad-hoc temporary profile. Based on Idea from http://blog.rabin.io/linux/start-chrome-temp-profile-with-preinstalled-extension
import tempfile
import os
import time
import configparser
import sys
import wx
def get_chrome_path_from_user():
app = wx.App(None)
style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
@ygilad
ygilad / coding_maxims.md
Created May 14, 2018 15:27 — forked from lyoshenka/coding_maxims.md
Keep this in mind when coding

Coding Maxims

  • code is debt (and bad code is a unhedged call option)
    • cant have 0-days or bugs if I dont write any code
    • our users dont care about the code
    • every line of code has costs (your time, readability, maintainability, complexity)
      • its like owning a house with lots of rooms. its nice when your friends come over once a month, but you pay rent every day
    • dont add features unless you're sure it is necessary
    • dont optimize prematurely
.____ .__
| | ____ ____ | |__
| | _/ __ \_/ ___\| | \
| |__\ ___/\ \___| Y \
|_______ \___ >\___ >___| /
\/ \/ \/ \/
____ __.
| |/ _|____ __________ _____ ____
| < / _ \/ ___/ _ \ / \ / _ \
@ygilad
ygilad / geras_riddle.py
Last active January 17, 2017 21:46
find numbers 4 numbers ranged(1-30) for which any combination of the numbers with + and - operator can result in all the numbers from 1 to 30
import itertools
def find_all_combinations(numbers):
ret = []
for L in range(0, len(numbers) + 1):
for subset in itertools.combinations(numbers, L):
if (len(subset)) > 0:
ret.append(list(subset))
return ret
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* SHA-1 implementation in JavaScript (c) Chris Veness 2002-2014 / MIT Licence */
/* */
/* - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html */
/* http://csrc.nist.gov/groups/ST/toolkit/examples.html */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* jshint node:true *//* global define, escape, unescape */
'use strict';
<Notification>
<NotificationMetaData>
<NotificationType>AnyOfferChanged</NotificationType>
<PayloadVersion>1.0</PayloadVersion>
<UniqueId>4e3a2c04-5f63-4afb-8666-e480e83fae47</UniqueId>
<PublishTime>2015-01-06T14:15:55.708Z</PublishTime>
<SellerId>A2H6E05OPYV8CQ</SellerId>
<MarketplaceId>ATVPDKIKX0DER</MarketplaceId>
</NotificationMetaData>
<NotificationPayload>