Skip to content

Instantly share code, notes, and snippets.

View itayadler's full-sized avatar

Itay Adler itayadler

View GitHub Profile
@itayadler
itayadler / jewish_weekend.rb
Created January 30, 2014 13:54
Ruby method for determining if the current time is during the jewish weekend
def jewish_weekend?(date=Time.now)
#Time.now.end_of_week will return sunday, so friday is -1 & saturday is -2
end_of_week = date.end_of_week
friday = end_of_week - 2.day
saturday = end_of_week - 1.day
(date.day == friday.day) || (date.day == saturday.day)
end
@itayadler
itayadler / screen_resolution.rb
Created April 1, 2014 10:42
A ruby module that retrieves the resolution details of your monitors - based on https://github.com/jhford/screenresolution
require 'active_support/core_ext/object/try'
class ScreenResolution
#ONLY FOR MAC
#Has a dependency on the screenresolution plugin. Install with it with `brew install screenresolution`
def self.get
#The screenresolution script output is going to STDERR (uses NSLog), so we redirect to STDOUT
raw_output = %x(screenresolution get 2>&1)
output = raw_output.split("\n")
@itayadler
itayadler / threepoly2tri.js
Last active August 29, 2015 14:00
Override THREE JS triangulateShape to use poly2tri.js
//three.js: https://github.com/mrdoob/three.js/
//poly2tri.js: https://code.google.com/p/poly2tri/
//Copied from: https://github.com/jahting/three.js/commit/b9774b00ca6a4f65deab2100d13a788802275a32 - triangulate2 function
THREE.Shape.Utils.triangulatePoly2Tri = function( pts, holes ) {
// For use with Poly2Tri.js
var allpts = pts.concat();
var shape = [];
for (var p in pts) {
@itayadler
itayadler / rename_files_in_dir_to_lowercase.sh
Created December 26, 2011 12:30
This bash script can be used to rename all the files in the current directory
#!/bin/bash
for i in *.*; do mv "$f" "${f,,}"; done
@itayadler
itayadler / cassandra-big-partitions.sh
Last active November 10, 2015 11:20
Prints out big partitions found during cassandra's compaction procedure
#!/bin/bash
set -e
#NOTE: Tested on cassandra 2.1 only, please leave a comment if this breaks on other versions.
#This script prints to stdout the big partitions cassandra is warning about during compaction.
#It goes over all the cassandra logs (all of the ones found on the server), and prints in ascending
#order the big partitions that were found during compaction.
#Usage example:
#ssh user@server.hostname 'bash -s' < big-partitions.sh
@itayadler
itayadler / gist:4297026
Created December 15, 2012 16:50
Spiral Printer
class NotSupportedArraySize < StandardError; end
class SpiralPrinter
def print(array)
finalResult = []
size = array.length
modulo = Math.sqrt(size).to_i
raise NotSupportedArraySize if modulo**2 != size
@itayadler
itayadler / imdb_db_downloader
Created October 17, 2013 21:08
A simple Ruby script I wrote to download the IMDB Plain Text DB. Simply save it as a file with executable permissions and it will hopefully work.
#!/usr/bin/env ruby --disable-gems
# vim: set ft=ruby:
require 'net/ftp'
require 'benchmark'
#Consts
IMDB_FTP_HOST = 'ftp.fu-berlin.de'
IMDB_FTP_DATA_PATH = '/pub/misc/movies/database'
README = <<-README
This is a simple Ruby script that downloads the entire IMDB Plain Text DB into a specified folder.
#!/bin/bash -e
#
# Copyright (C) 2015 ScyllaDB
# Modified by Itay Adler to fit for ComboAMI DSE setup.
print_usage() {
echo "dse-raid-setup --disks /dev/hda,/dev/hdb... --raiddev /dev/md0 --update-fstab"
echo " --disks specify disks for RAID"
echo " --raiddev MD device name for RAID"
echo " --update-fstab update /etc/fstab for RAID"
@itayadler
itayadler / docker-compose.yml
Created August 4, 2018 21:33
A docker-compose for a client/api/db+migrations app
version: '2.1'
services:
api:
build:
context: ./api/
command: /usr/app/node_modules/.bin/nodemon index.js
volumes:
- ./api/:/usr/app
- /usr/app/node_modules
@itayadler
itayadler / nslookup_list.sh
Last active August 20, 2018 11:00
Run nslookup on a list of domains
#!/bin/bash
set -e
usage() {
echo "Runs nslookup on a list of domains given by a text file, each domain separated by a newline."
echo "Usage: path_to_textfile.txt"
exit 1
}