Skip to content

Instantly share code, notes, and snippets.

View Abhinav1217's full-sized avatar

Abhinav Kulshreshtha Abhinav1217

View GitHub Profile
@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"
@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
@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){
@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'"
// 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
@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.

@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)
{
@PasanBhanu
PasanBhanu / CheckNetwork.java
Last active July 25, 2023 13:28
Check Internet Connection in Android (API Level 29) Using Network Callback
/*
You need to call the below method once. It register the callback and fire it when there is a change in network state.
Here I used a Global Static Variable, So I can use it to access the network state in anyware of the application.
*/
// You need to pass the context when creating the class
public CheckNetwork(Context context) {
this.context = context;
}
@slimsag
slimsag / ramblings.md
Last active December 13, 2023 08:02
Because cross-compiling binaries for Windows is easier than building natively

Because cross-compiling binaries for Windows is easier than building natively

I want Microsoft to do better, want Windows to be a decent development platform-and yet, I constantly see Microsoft playing the open source game: advertising how open-source and developer friendly they are - only to crush developers under the heel of the corporate behemoth's boot.

The people who work at Microsoft are amazing, kind, talented individuals. This is aimed at the company's leadership, who I feel has on many occassions crushed myself and other developers under. It's a plea for help.

The source of truth for the 'open source' C#, C++, Rust, and other Windows SDKs is proprietary

You probably haven't heard of it before, but if you've ever used win32 API bindings in C#, C++, Rust, or other languages, odds are they were generated from a repository called microsoft/win32metadata.

@averj
averj / Converter.java
Last active January 22, 2024 00:47
Roman Numeral Converter
package me.javersano.cs;
public class Converter {
public final int[] NUMBER_VALUES = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; // array containing all of the values
public final String[] NUMBER_LETTERS = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" }; // array containing all of the numerals
/**
* Method used to convert a string to a integer
* @param roman roman numeral to be converted