Skip to content

Instantly share code, notes, and snippets.

@tahir-hassan
tahir-hassan / GetCircleFromPoints.ps1
Created July 18, 2021 17:01
PowerShell code to get a circle from three points on an arc.
class Point {
[double]$X;
[double]$Y;
Point([double]$x, [double]$y) {
$this.X = $x;
$this.Y = $y;
}
[Point]Add([double]$xDelta, [double]$yDelta) {
@IAmSuyogJadhav
IAmSuyogJadhav / Transparent drawings in OpenCV.py
Created July 10, 2018 09:41
Add transparency to rectangles, circles, polgons, text or any shape drawn in OpenCV.
import cv2
image = cv2.imread('test.jpg')
overlay = image.copy()
x, y, w, h = 10, 10, 10, 10 # Rectangle parameters
cv2.rectangle(overlay, (x, y), (x+w, y+h), (0, 200, 0), -1) # A filled rectangle
alpha = 0.4 # Transparency factor.
@ayamflow
ayamflow / rotate-uv.glsl
Created January 16, 2018 23:24
Rotate UV in GLSL
vec2 rotateUV(vec2 uv, float rotation)
{
float mid = 0.5;
return vec2(
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
);
}
vec2 rotateUV(vec2 uv, float rotation, vec2 mid)
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <ctime>
int main()
{
int start_c = 10000, end_c = 20000;
@inancgumus
inancgumus / gist:71a72f472343f38b27b4e53ea4d00acb
Last active October 20, 2020 22:15
Restore github commit

If you've made a wrong forceful push or just want to recover from old commits in github, then you can use this command flow:

# find the commit, just like git reflog
curl -u <username> https://api.github.com/repos/:owner/:repo/events

# create a new branch from the commit sha found in previous step
curl -u <github-username> 
  -X POST -d ‘{“ref”:”refs/heads/<new-branch-name>”, “sha”:”<sha-from-step-1>"}’ 
 https://api.github.com/repos/:owner/:repo/git/refs
@fredrick
fredrick / String.format.js
Created May 16, 2011 22:28
printf()/format() for JavaScript String
/*
* Extend JavaScript String object with printf() like functionality
* "{0} is dead, but {1} is alive!".format("This", "that");
*/
String.prototype.format = function() {
var formatted = this;
for(arg in arguments) {
formatted = formatted.replace("{" + arg + "}", arguments[arg]);
}
return formatted;
@bradfordcp
bradfordcp / Syns2Syms.java
Created September 2, 2010 19:12
Converts a WordNet prolog file into a flat file useful for Solr synonym matching.
/**
* Based off of the Lucene prolog parser in the wordnet contrib package within the
* main Lucene project. It has been modified to remove the Lucene bits and generate
* a synonyms.txt file suitable for consumption by Solr. The idea was mentioned in
* a sidebar of the book Solr 1.4 Enterprise Search Server by Eric Pugh.
*
* @see <a href="http://lucene.apache.org/java/2_3_2/lucene-sandbox/index.html#WordNet/Synonyms">Lucene Sandbox WordNet page</a>
* @see <a href="http://svn.apache.org/repos/asf/lucene/dev/trunk/lucene/contrib/wordnet/">SVN Repository of the WordNet contrib</a>
* @see <a href="https://www.packtpub.com/solr-1-4-enterprise-search-server/book">Solr 1.4 Enterprise Search Server Book</a>
*/