Skip to content

Instantly share code, notes, and snippets.

@perrmadiafrrian
perrmadiafrrian / remove_local_branch.sh
Created January 27, 2022 08:29
Removing all local branch except `master` or `main`
#!/bin/sh
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main" | xargs git branch -D
@perrmadiafrrian
perrmadiafrrian / nginx-tuning.md
Last active March 26, 2020 14:24 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@perrmadiafrrian
perrmadiafrrian / phpwrapper
Created March 26, 2020 09:32
Php Wrapper for VSCode extension who need the php executeable path (Linux)
#!/bin/sh
docker run \
--rm \
-i \
--network=host \
-v "$HOME":"$HOME":ro \
-u $(id -u) \
-w "$PWD" \
php:alpine \
FROM php:fpm-alpine
#MySQL Driver
RUN docker-php-ext-install mysqli pdo pdo_mysql
#SQL Server Driver
RUN curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.2.1-1_amd64.apk && \
curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_17.5.2.1-1_amd64.apk && \
apk add --allow-untrusted msodbcsql17_17.5.2.1-1_amd64.apk && \
apk add --allow-untrusted mssql-tools_17.5.2.1-1_amd64.apk && \
@perrmadiafrrian
perrmadiafrrian / example.md
Created March 13, 2020 01:17 — forked from devdrops/example.md
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯
@perrmadiafrrian
perrmadiafrrian / BCrypt.java
Created October 13, 2018 15:07
Java BCrypt Modified
// Copyright (c) 2006 Damien Miller <[email protected]>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@perrmadiafrrian
perrmadiafrrian / Highscore.cs
Created May 1, 2018 09:40
Simple Highscore on multiple level using dreamlo.com : json
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Highscore : MonoBehaviour
{
const string privateCode = "secret";
Shader "Custom/Lighting/Emission"
{
Properties
{
[Header(Diffuse)]
_Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0)
_Diffuse ("Diffuse value", Range(0, 1)) = 1.0
[Header(Emission)]
_MainTex ("Emissive Map", 2D) = "white" {}
[HDR] _EmissionColor ("Emission Color", Color) = (0,0,0)
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
namespace Cluster {
public class CollisionCall : MonoBehaviour {
public LayerMask layerMask = -1;