Skip to content

Instantly share code, notes, and snippets.

View kanasite's full-sized avatar
:shipit:
Eat Sleep Code Repeat

0xkns kanasite

:shipit:
Eat Sleep Code Repeat
View GitHub Profile
@kanasite
kanasite / remove_plots.sh
Last active April 11, 2023 01:34
Remove Old plots by Interval
#!/bin/bash
## USAGE
## ./remove_plots.sh /PATH/TO/DIRECTORY/ 2021-07-01 30m
## first argument is path, must be end with trailing "/"
## second argument is target date, meaning plots that created after this date WILL NOT BE DELETED, if you specify 2021-07-01, only filename containing 2021-06-30 or before wil be deleted.
## third argument is the interval, adjust yourself according to your plotting speed or how soon you want to trigger next deletion.
SOURCE_DIR=$1
TARGET_DATE=${2:-"2021-07-01"}
INTERVAL=${3:-"30m"}

Keybase proof

I hereby claim:

  • I am kanasite on github.
  • I am kanasite (https://keybase.io/kanasite) on keybase.
  • I have a public key ASCYYs6_BsEgS0RMiYmDinDGTkmpQSOZCnvuaDmCrXJtggo

To claim this, I am signing this object:

@kanasite
kanasite / coco.sh
Last active October 1, 2020 05:46 — forked from mkocabas/coco.sh
Download COCO dataset. Run under 'datasets' directory.
mkdir coco
cd coco
mkdir images
cd images
wget -c http://images.cocodataset.org/zips/train2017.zip
wget -c http://images.cocodataset.org/zips/val2017.zip
wget -c http://images.cocodataset.org/zips/test2017.zip
wget -c http://images.cocodataset.org/zips/unlabeled2017.zip
@kanasite
kanasite / resize.960.command
Created June 26, 2018 15:36
Batch Resize images
#!/bin/bash
# This script resizes all the images it finds in a folder (and its subfolders) and resizes them
# The resized image is placed in the /resized folder which will reside in the same directory as the image
#
# Usage: > ./batch_resize.sh
initial_folder="$(dirname "$BASH_SOURCE")" # You can use "." to target the folder in which you are running the script for example
resized_folder_name="resized_960"
all_images=$(find -E $initial_folder -iregex ".*\.(jpg|gif|png|jpeg)")
@kanasite
kanasite / PG_KILL_SESSION
Created May 26, 2017 06:40
KILL ALL POSTGRES SESSION
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid();
#!/usr/bin/env bash
while getopts ":s:" opt; do
case $opt in
s)
webserver_container=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
@kanasite
kanasite / rename.php
Created November 24, 2016 02:01
Rename file to uuid.mp4
<?php
$handle = fopen("/Volumes/WD/matched_video.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
// OK: 3d46074a-6502-4600-9816-88a16bf51ac9--------$filename
$uuid = substr($line, 4, 36);
$filename = substr($line, 48);
$filename_without_extension = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
if(rename("/Volumes/WD/final/".$uuid."/".$filename, "/Volumes/WD/final/".$uuid."/".$filename_without_extension.".mp4")){
<?php
/*
* Plugin Name: Woocommerce Rounding
* Description: Round woocommerce orders total
* Plugin URI: http://www.amintaibouta.com
* Author: Amin T.
* Author URI: http://www.amintaibouta.com
* Version: 1.0
*/
@kanasite
kanasite / route
Created February 25, 2016 08:13
Laravel Route Pattern
// This is what you might have right now
Route::get('users/{id}', 'UserController@getProfile')->where('id', '[\d+]+');
Route::get('products/{id}', 'ProductController@getProfile')->where('id', '[\d+]+');
Route::get('articles/{slug}', 'ArticleController@getFull')->where('slug', '[a-z0-9-]+');
Route::get('faq/{slug}', 'FaqController@getQuestion')->where('slug', '[a-z0-9-]+');
// and many more, now imagine you'll have to change the rule
// Instead, you could have a handy list of patterns and reuse them everywhere:
// Patterns
Route::pattern('id', '\d+');

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables