Skip to content

Instantly share code, notes, and snippets.

View mastef's full-sized avatar
🤗

mastef mastef

🤗
View GitHub Profile
@mastef
mastef / isexist_vs_isnotexist.go
Created February 4, 2016 08:30
os.IsExist(err) vs os.IsNotExist(err)
/*
Watch out, os.IsExist(err) != !os.IsNotExist(err)
They are error checkers, so use them only when err != nil, and you want to handle
specific errors in a different way!
Their main purpose is to wrap around OS error messages for you, so you don't have to test
for Windows/Unix/Mobile/other OS error messages for "file exists/directory exists" and
"file does not exist/directory does not exist"
@mastef
mastef / clone_and_restore_server_harddisk.md
Created August 1, 2023 07:49 — forked from nisanthchunduru/clone_and_restore_server_harddisk.md
Clone and restore a physical server's harddisk

Clone a server's harddisk

Login to Hetzner's web interface https://robot.your-server.de/ and activate the Rescue System for the server whose disk you wish to clone.

Ssh into the Rescue System (Replace 1.2.3.4 in the command below with the actual ip address of the server)

ssh -o HostKeyAlias=hetzner-rescue.1.2.3.4 root@1.2.3.4
@mastef
mastef / gist:9a84666759796ae9df65edde69130465
Last active June 10, 2022 13:03
Extract Pricing template from Google Play Console to .csv format
// Go to "All Applications" / "Settings" / "Pricing templates" and select the template you want to export
javascript: (function(e, s) {
e.src = s;
e.onload = function() {
jQuery.noConflict();
console.log('jQuery injected');
$ = jQuery;
extractData();
};
@mastef
mastef / functions.php
Last active January 31, 2022 06:50
Pods : How to add Custom Admin Table Columns to a Pods ACT
<?php
/*
only important name is the filter name :
pods_admin_ui_PODNAME
if your pods is called "client" then call it
pods_admin_ui_client
you can rename all functions to your liking
*/
add_filter( 'pods_admin_ui_PODNAME', 'custom_admin_table_columns_for_PODNAME' );
@mastef
mastef / anything.js
Created February 12, 2019 08:22
hltv toggle comment threads on click
$('.post').off('click')
function postClick() {
console.log($(this));
var results = $(this).nextUntil('.post');
var a = 0;
for(i=0;i<results.length;i++) {
if($(results[0]).hasClass('threading')) {
a++;
$(results[0]).toggle();
@mastef
mastef / circular.hx
Created July 11, 2018 11:52
haxe json circular reference patch
var _data:Dynamic = ...;
var cache:Array<Dynamic> = [];
var jsonString = haxe.Json.stringify(_data, function(key:Dynamic, value:Dynamic) {
// kill keys you don't want here
// if(key == "ba") return null;
// only filter objects
if(value != null && Reflect.isObject(value)) {
if(cache.indexOf(value) > -1) {
@mastef
mastef / HTML5Application.hx
Last active February 4, 2018 02:35
openfl - Hunt for 24 fps part 2
package lime._backend.html5;
import js.html.KeyboardEvent;
import js.Browser;
import lime.app.Application;
import lime.app.Config;
import lime.media.AudioManager;
import lime.graphics.Renderer;
import lime.ui.GamepadAxis;
@mastef
mastef / Trace.hx
Created January 18, 2018 08:41
haxe trace to console.log with objects instead of strings
// check browser console in https://try.haxe.org/#cFBDb
class Trace {
static function main() {
var a = {};
Reflect.setProperty(a, "b", "c");
trace("before");
trace("a");
@mastef
mastef / Dockerfile
Last active December 10, 2017 08:48
openfl-modular testing
FROM openfl/openfl:develop
## install node/npm
ADD https://deb.nodesource.com/setup_8.x /opt/node8setup.sh
RUN chmod +x /opt/node8setup.sh && /opt/node8setup.sh
RUN apt-get install -y --no-install-recommends nodejs
## tests need these modules, let's have them in global namespace
RUN npm install http-server -g
RUN npm install webpack -g
@mastef
mastef / crontab
Last active November 14, 2017 08:37
Remember wifi names and ip addresses - in case the router's dhcp stops working you can still reconnect to it
# chmod +x wifiremember.sh, then
# type `crontab -e` and add this line :
* * * * * $HOME/wifiremember/wifiremember.sh