Skip to content

Instantly share code, notes, and snippets.

View Abhinav1217's full-sized avatar

Abhinav Kulshreshtha Abhinav1217

View GitHub Profile
@CHH
CHH / MetaObject.php
Created August 30, 2011 13:55
PHP does Meta Programming too! (Requires PHP 5.4)
<?php
namespace CHH;
trait MetaObject
{
protected static $__metaClass;
static function setMetaClass(MetaClass $metaClass)
{
@korya
korya / Login shell vs Subshell.md
Last active May 15, 2023 22:36
.bashrc vs .bash_profile

.profile, .bash_profile, .bashrc. The Long Story.

Traditionally, when you log into a Unix system, the system would start one program for you. That program is a shell, i.e., a program designed to start other programs. It's a command line shell: you start another program by typing its name. The default shell, a Bourne shell, reads commands from ~/.profile when it is invoked as the login shell.

Bash is a Bourne-like shell. It reads commands from ~/.bash_profile when it is invoked as the login shell, and if that file doesn't exist¹, it tries reading ~/.profile instead.

// Brightness math based on:
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
// Extract color components
@saeidzebardast
saeidzebardast / youtube-dl-playlist
Last active April 29, 2022 16:12
Download Youtube playlist in a folder and indexing videos using youtube-dl
alias youtube-dl-playlist="youtube-dl --ignore-errors --output '%(playlist)s/%(playlist_index)s- %(title)s.%(ext)s'"
@JosephShenton
JosephShenton / ddosl7.php
Created September 8, 2017 03:38
Layer 7 DDoS Protection PHP
<?php
$key = "La1az>T.}+w:uMoZ"; // CHANGE THIS STRING
$code = md5($_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_HOST'].$key);
$cookie = isset($_COOKIE['l7code']) ? $_COOKIE['l7code'] : FALSE ;
$ignored_uri = array();
$ignore = false;
foreach($ignored_uri as $u){
@sekimura
sekimura / gist:6367366
Last active December 10, 2021 16:56
phabricator workflow
  • create tasks T{NNNN} asign them
  • create a branch with name like "T{NNNN}-boo-hoo"
  • git checkout -b T1234-boo-foo
  • commit changes on that branch until it gets ready to be reviewed
  • git commit -am 'first'
  • git commit -am 'now it works'
  • check if it's lint free (NOTE: it runs lint against only modified files)
  • arc lint
  • push a review request to the server. This will create a diff with id D{NNNN}
  • arc diff
@gotbletu
gotbletu / comic2cbz
Created August 30, 2021 19:46
comic2cbz - convert images to webp at 50% quality and create cbz (comicbook archive)"
#!/usr/bin/env bash
# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
helpmsg() {
printf "%s\n" "desc: convert images to webp at 50% quality and create cbz (comicbook archive)"
printf "%s\n" "depend: imagemagick zip coreutils libwebp"
printf "\n"
printf "%s\n" "usage: ${0##*/} <image>"
printf "\n"
printf "%s\n" " $ ${0##*/} *.png"