Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
hi ✌️

Suat Secmen FirePanther

👨‍💻
hi ✌️
View GitHub Profile
View svg-to-png.php
<?php
$settings = [];
// svg file
if (isset($_GET['svg'])) {
// general/custom svg file
$svgFile = DIR_ASSETS.'/cdn/dist/svg/'.$_GET['svg'];
if (!preg_match('~^\w[\w/-]+\.svg$~', $_GET['svg']) || !file_exists($svgFile)) die('Invalid svg');
} elseif (isset($_GET['fa'])) {
// fontawesome icon
View Hue.class.php
<?php
// @author: su.at (made for myself)
class Hue {
private static $ip = '___ADD-HUE-IP-ADDRESS-HERE___';
private static $user = '___ADD-USER-ID-HERE___';
// private methods
private static function request($method, $api, $body) {
$url = self::$user.'/'.$api;
@FirePanther
FirePanther / .eslintrc.json
Created Sep 3, 2018
my eslint rules and settings
View .eslintrc.json
{
"env": {
"browser": true
},
"parserOptions": {
"ecmaVersion": 5
},
"rules": {
"no-undef": 0,
"no-cond-assign": [
@FirePanther
FirePanther / speedtest.php
Created Jan 11, 2017
Quickly compare the speed of multiple functions
View speedtest.php
<?php
/**
* Example output:
* function: file_exists(__FILE__);
* time: 1.39806 seconds
* speed: 39.248 %
*
* function: is_file(__FILE__);
* time: 0.3417 seconds
* speed: 85.152 %
@FirePanther
FirePanther / ToDo-FinderTag.sh
Last active Dec 10, 2016
This cron shell script automatically adds a ToDo Finder Tag to all files, which contains a comment like "// todo: replace"
View ToDo-FinderTag.sh
# you will need https://github.com/jdberry/tag for finder tags (and correct the path)
{
grep -rlIi --null -E -e "(\#|//|/\*\*?)\s*todo\b" --exclude-dir="Library" --exclude-dir="node_modules" --include=\*.{php,js,css,htm,html} "$HOME" | xargs -0 .../execs/tag -a "ToDo"
} &> /dev/null
@FirePanther
FirePanther / suat.be-FinderTags.sh
Last active Dec 10, 2016
I recently moved to another Domain (from suat.be to su.at). This cron script automatically adds a "suat.be" Finder tag to all files which contains this string (so I can replace it with su.at)
View suat.be-FinderTags.sh
# you will need https://github.com/jdberry/tag for finder tags (and correct the path)
{
grep -rlI --null "suat.be" --exclude-dir=".git" --exclude-dir="Library" --exclude-dir="Mail Attachments" --exclude-dir="Paperwork" --exclude="*.log" --exclude="*.eml" --exclude="minibackups.sh" "$HOME" | xargs -0 .../execs/tag -a "suat.be"
} &> /dev/null
@FirePanther
FirePanther / autoFinderGitTag.sh
Last active Nov 19, 2016
Automatically adds a Finder "Git" Tag to all your repos
View autoFinderGitTag.sh
#!/bin/bash
# requires 'tag' binary from https://github.com/jdberry/tag
# auto git tag
{
find $HOME -type d \
! -path '*Trash' \
-name ".git" -exec dirname {} \; | while read line; do \
./tag -a Git "$line"; done
View recursiveScandir.php
<?php
sd('./', parseFile);
/**
* recursive scandir
*/
function sd($d, $cb) {
$s = scandir($d);
foreach ($s as $f) {
if ($f[0] == '.') continue;
@FirePanther
FirePanther / permanentlyDelete.gs
Last active Nov 8, 2016
Permanenty delete some Google Drive files from the trash. After I've watched the Videos in my YouTube folder I remove them but they still take much space in my Google Drive.
View permanentlyDelete.gs
/**
* Permanenty delete some Google Drive files from the trash.
*/
function run() {
var trashed = DriveApp.getTrashedFiles();
while (trashed.hasNext()) {
parseTrashedFile(trashed.next());
}
}
@FirePanther
FirePanther / downloadYoutubeChannel.php
Last active Nov 17, 2016
download all youtube videos of channels
View downloadYoutubeChannel.php
<?php
/**
* @author FirePanther (http://suat.be)
* @copyright DevMe (http://devme.de)
* @description youtube.php: Download all videos of channels
* @date 17/04/16
* @dependencies - youtube-dl (same location): https://yt-dl.org/downloads/2016.04.13/youtube-dl
* - brew: AtomicParsley, coreutils (gtouch, gecho)
*/