Skip to content

Instantly share code, notes, and snippets.

View podrezo's full-sized avatar

Petro Podrezo podrezo

View GitHub Profile
@podrezo
podrezo / branch_list.sh
Created December 14, 2021 15:46
CSV of Remote Branches
#!/bin/bash
echo "\"Branch Name\",\"Last Commit Date\",\"Last Commit Date (ago)\",\"Last Commit By\""
for branch in `git branch -r --merged master | grep -v HEAD`
do
git show --format="\"$branch\",\"%ci\",\"%cr\",\"%an\"" $branch | head -n 1
done
@podrezo
podrezo / Linux Snippets.md
Created February 27, 2021 18:57
Snippets of useful linux commands

Firewall (UFW)

Common service

ufw allow ssh 

Port number

ufw allow 2222 
@podrezo
podrezo / appsscript.json
Created September 10, 2020 02:30
Google Data Studio Connector: Toronto City Council Attendance
{
"timeZone": "America/Toronto",
"dependencies": {},
"dataStudio": {
"name": "Toronto City Council Attendance",
"logoUrl": "https://i.imgur.com/e9wE7Md.png",
"company": "Petro Podrezo",
"companyUrl": "https://toronto.ca/",
"addonUrl": "https://toronto.ca/",
"supportUrl": "https://toronto.ca/",
@podrezo
podrezo / interval_tree.js
Created August 24, 2020 23:05
An interval tree written in JS to find the number of intersecting intervals at a given point
// https://en.wikipedia.org/wiki/Interval_tree
export default class IntervalTree {
// intervals is a two dimensional array of "from" and "to" values
// the values can be of any type. If they can directly be compared
// using greater/lesser than operators then a compare function does
// not need to be supplied
constructor(intervals) {
this.allIntervals = intervals.map(interval => new Interval(interval[0], interval[1]));
this.root = new IntervalTreeNode(this.allIntervals);
@podrezo
podrezo / ruby_memory_test.rb
Created July 5, 2018 15:04
Show the heap and stack in action using ruby
class MyClass
attr_writer :my_value
end
def my_function(i)
return if i.zero?
my_stack_var = MyClass.new
# "Each slot is big enough to hold one Ruby object"
puts "heap_free_slot -> #{GC.stat[:heap_free_slot]}, stack_size -> #{caller.size}"
my_function(i-1)
@podrezo
podrezo / pmap.rb
Created May 14, 2018 00:55
Implement "map" function from ruby's arrays to understand how blocks work
require 'minitest/autorun'
# Good blog article https://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods
# Extends 'Array' adding the pmap method which is equivalent to map
class Array
# def pmap(&block)
# map(&block)
# end
def pmap(&block)
@podrezo
podrezo / scrollToEnd.js
Last active July 25, 2023 07:13
This angular.js directive can detect when an element or the window itself scrolls to any edge, then calls a handler with the edge that was hit.
'use strict';
// Tested with Angular 1.3, 1.4.8
angular.module('scrollToEnd', [])
/**
* @ngdoc directive
* @name scrollToEnd:scrollToEnd
* @scope
* @restrict A
*
* @description
@podrezo
podrezo / 488.vim
Created January 10, 2016 04:55
CSC488 Winter 2012 Project Language VIM Syntax Highlighting File
" Vim syntax file
" Language: CSC488 Project Language
" Maintainer: Petro Podrezo
" Latest Revision: 18 January 2012
if exists("b:current_syntax")
finish
endif
" ################### Define Keywords ####################
@podrezo
podrezo / MainWindow.xaml.cs
Created December 3, 2015 20:28
Interacting with Embedded Chromium and Embedded IE in .NET/WPF
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// Initialize Internet Explorer
@podrezo
podrezo / qr.js
Created June 23, 2015 22:35
ZBar Node.js QR Code
'use strict';
var exec = require('child_process').exec;
module.exports = function(callback) {
exec('"C:\\Program Files (x86)\\ZBar\\bin\\zbarimg.exe" --raw --quiet capture.png', function(err, stdout, stderr){
if(err) { return callback(err); }
return callback(null, stdout.substring(0,stdout.length-1));
});
}