Skip to content

Instantly share code, notes, and snippets.

View darkworks's full-sized avatar
🏠
Working from home

darkworks

🏠
Working from home
View GitHub Profile
@darkworks
darkworks / secure_link.php
Last active January 12, 2022 05:55 — forked from bftanase/secure_link.php
generate URL for nginx secure_link #nginx #linux
@darkworks
darkworks / angle-between-points.js
Last active July 14, 2018 09:29 — forked from conorbuck/angle-between-points.js
JavaScript: Find the angle between two points
// FInd Angle between 2 point ... 0 to 90
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
@darkworks
darkworks / color-conversion-algorithms.js
Last active June 21, 2018 07:02 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@darkworks
darkworks / simple-pagination.js
Created May 2, 2018 16:58 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Canvas Transformation</title>
</head>
<body>
<script>
// Create our canvas and append it to the document body
var stage = document.createElement("canvas");
@darkworks
darkworks / vboxdrvfix.md
Created January 31, 2018 06:38 — forked from PartTimeLegend/vboxdrvfix.md
/etc/init.d/vboxdrv setup Not Found - VirtualBox Fix!

#/etc/init.d/vboxdrv setup Not Found - VirtualBox Fix!

When setting up Virtual Box I was faced with the immortal error telling me to run sudo /etc/init.d/vboxdrv setup. Simple enough, until you're told it doesn't exist.

Thus began my fight to get it working. The fix is here in the hope that it helps someone else.

To follow this guide you need to have a basic understanding of shell commands. If you don't, then just be careful.

First off I like aptitute so let's install it.

@darkworks
darkworks / spectre.c
Created January 5, 2018 06:10 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@darkworks
darkworks / array_dupplicate_counter.js
Created June 6, 2017 07:17 — forked from ralphcrisostomo/array_dupplicate_counter.js
Javascript: Count duplicates in an array
/**
Problem:
You have a javascript array that likely has some duplicate values and you would like a count of those values.
Solution:
Try this schnippet out.
*/
@darkworks
darkworks / latest-ffmpeg-centos6.sh
Last active March 3, 2017 05:34 — forked from mustafaturan/latest-ffmpeg-centos6.sh
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@darkworks
darkworks / gist:f3ca38655429222eda0cf455338bc94f
Created December 4, 2016 12:39 — forked from jameshartig/gist:2357002
Get MP3 bit rate and sample rate in PHP
//returns an assoc array with bitRate (kbps) and sampleRate (hz)
function getMP3BitRateSampleRate($filename)
{
if (!file_exists($filename)) {
return false;
}
$bitRates = array(
array(0,0,0,0,0),
array(32,32,32,32,8),