Skip to content

Instantly share code, notes, and snippets.

View eladg's full-sized avatar

Elad Gariany eladg

View GitHub Profile
@eladg
eladg / pre-commit.sh
Created August 27, 2021 23:48
prevent commit on master/dev/prod branches
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ] || [ "$branch" = "dev" ] || [ "$branch" = "prod" ]; then
echo "You can't commit directly to $branch branch"
exit 1
fi
@eladg
eladg / ffmpeg-crt-filter.sh
Created May 14, 2020 00:31
FFmpeg filter for CRT SCAN lines
# you will need these files:
# -> https://www.gariany.com/2020/05/ffmpeg-crt-scan-lines-filter/scanline_pattern_croped.png
ffmpeg -loglevel debug -y -f lavfi -i color=c=black:s=1216x896 -filter_complex "movie='bg_croped.png',format=rgba,setsar=1:1[bgc];movie='scanline_pattern_croped.png'[spc];movie='main.png',format=rgba,scale=iw:ih*4:flags=neighbor,scale=iw*4:ih:flags=bilinear[input];[bgc][input]overlay[tmp];[tmp][spc]blend=all_mode=softlight:all_opacity=0.15[tmp2];[0][tmp2]overlay[o]" -map "[o]" -frames:v 1 output.png
@eladg
eladg / openport2pid.sh
Created April 15, 2019 11:35
Openport2pid
#!/bin/bash
# Original at: http://www.brandonhutchinson.com/Port_to_PID_with_lsof.html
# was written originaly for Solaris 9. Fixed By Elad Gariany to OSX
# Map LISTENing TCP ports to their PIDs using lsof
#LSOF=lsof
# e.g. netstat -an
# 127.0.0.1.25 *.* 0 0 49152 0 LISTEN
# *.22 *.* 0 0 49152 0 LISTEN
var simplexPeer = new function() {
// const
this.ICE_SERVERS = [{
urls: "stun:stun.l.google.com:19302",
}
]
this.CHANNEL_KEY = 'webrtc/channel';
this.SENDER_KEY = 'webrtc/sender-description';
var canvas = document.getElementById('heatmap-canvas');
var gl = canvas.getContext('webgl');
var debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
var vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
var renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
console.log(vendor);
console.log(renderer);
@eladg
eladg / Heights-shader.frag
Last active November 22, 2022 06:24
WebGL-HeatMap - Shaders in GLSL
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp int;
precision highp float;
#else
precision mediump int;
precision mediump float;
#endif
varying vec2 off, dim;
varying float vIntensity;
@eladg
eladg / Equirectangular-to-Stereographic-Projection-Shader.frag
Last active March 29, 2017 06:42
WebGL: stereoscopic projection transformation (Fragment Shader)
// credits to: https://github.com/notlion/streetview-stereographic
precision mediump float;
uniform sampler2D texture;
uniform float scale, aspect, time;
uniform mat3 transform;
varying vec2 v_texcoord;
@eladg
eladg / bundle.js
Created July 18, 2016 06:20
Simple ReactJS Contacts App
var app = app || {};
(function() {
'use strict';
var ContactsApp = React.createClass({
getInitialState: function() {
// was considering a hash design which would
@eladg
eladg / project_spec.rb
Created December 29, 2015 04:15
rspec model popular describe block
require 'rails_helper'
RSpec.describe Project, type: :model do
let(:model) { described_class }
describe 'validation' do
end
describe "associations" do
end
@eladg
eladg / mess-unfollow-twitter.js
Created October 4, 2015 20:29
Mess Unfollow clicking on Twitter /following page (Oct. 2015)
__cnt__=0; jQuery('button.user-actions-follow-button > span.following-text').each(function (i, ele) { ele = jQuery(ele); if (ele.css('display')!='block') {console.log('already following:', i); return;} setTimeout(function () {ele.click();}, __cnt__++*500); });