Skip to content

Instantly share code, notes, and snippets.

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

Celman Abbas celmanabbas

🏠
Working from home
  • Remote
View GitHub Profile
class DeferredPromise extends Promise {
constructor(def = (res, rej)=>{}) {
let res, rej;
super((resolve, reject)=>{
def(resolve, reject);
res = resolve;
rej = reject;
});
this.resolve = res;
@celmanabbas
celmanabbas / generate-client.sh
Created April 23, 2021 01:29 — forked from Belphemur/generate-client.sh
Generate a new client configuration for WireGuard
#!/usr/bin/env bash
if [ -z "$1" ]
then
echo "$0 client-name"
exit 1
fi
@celmanabbas
celmanabbas / unit.sh
Created February 18, 2021 22:16 — forked from tvlooy/unit.sh
Bash test: get the directory of a script
#!/bin/bash
function test {
MESSAGE=$1
RECEIVED=$2
EXPECTED=$3
if [ "$RECEIVED" = "$EXPECTED" ]; then
echo -e "\033[32m✔︎ Tested $MESSAGE"
else
(function(w, d, undefined){
if( w.onfocusin === undefined){
d.addEventListener('focus', addPolyfill, true);
d.addEventListener('blur', addPolyfill, true);
d.addEventListener('focusin', removePolyfill, true);
d.addEventListener('focusout', removePolyfill, true);
}
function addPolyfill(e){
var type = e.type === 'focus' ? 'focusin' : 'focusout';
@celmanabbas
celmanabbas / designer.html
Last active August 29, 2015 14:10
designer
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-menu-button/core-menu-button.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
<polymer-element name="my-element">
<template>
<style>
function create_guid() {
$random_bytes = '';
if (function_exists('mcrypt_create_iv')) {
$random_bytes .= @mcrypt_create_iv(100, MCRYPT_DEV_URANDOM);
}
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { // Unix
if ($fp = @fopen('/dev/urandom','rb')) {
$random_bytes .= @fread($fp, 100);
@celmanabbas
celmanabbas / README.md
Created November 17, 2012 15:42 — forked from mbostock/.block
Line Chart
<b>Sallu Rocks!</b>
@celmanabbas
celmanabbas / code.php
Created November 25, 2011 15:04
Grab youtube video download URLs
preg_match("/yt\.setConfig\(\{\s+\'PLAYER_CONFIG\'\:\s(?<config>.*?)\s+\}\)/s", $page, $matches);
$config = json_decode($matches['config']);
$fmts = explode(',', $config->args->url_encoded_fmt_stream_map);
foreach( $fmts as $k => $v ) { parse_str($v, $fmts[$k]); }
@celmanabbas
celmanabbas / code.php
Created November 25, 2011 15:03
Get youtube video download URLs
preg_match("/yt\.setConfig\(\{\s+\'PLAYER_CONFIG\'\:\s(?<config>.*?)\s+\}\)/s", $page, $matches);
$config = json_decode($matches['config']);
$fmts = explode(',', $config->args->url_encoded_fmt_stream_map);
foreach( $fmts as $k => $v ) { parse_str($v, $fmts[$k]); }