Skip to content

Instantly share code, notes, and snippets.

View rizalp's full-sized avatar

Mohammad Shahrizal Prabowo rizalp

View GitHub Profile
@rizalp
rizalp / zram-ubuntu-1804.md
Last active October 22, 2023 12:06
Zram Ubuntu 1804
  • sudo apt install zram-config, this will install several files, including systemd startup /etc/systemd/system/multi-user.target.wants/zram-config.service
  • sudo nano /usr/bin/init-zram-swapping and edit:
#!/bin/sh

# load dependency modules
NRDEVICES=1
if modinfo zram | grep -q ' zram_num_devices:' 2>/dev/null; then
 MODPROBE_ARGS="zram_num_devices=${NRDEVICES}"
@rizalp
rizalp / mysql2 gem with mysql 5.7 brew
Last active August 10, 2023 02:58
install mysql2 gem by linking it with mysql 5.7 homebrew
brew install mysql@5.7
gem install mysql2 -v '0.4.8' -- --with-ldflags=-L/usr/local/opt/mysql@5.7/lib --with-cppflags=-I/usr/local/opt/mysql@5.7/include
@rizalp
rizalp / disable_spectre.md
Last active May 22, 2023 22:07
Disable Spectre/Meltdown Mitigation

In /etc/default/grub, modify:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off tsx=on tsx_async_abort=off mitigations=off"

Then sudo update-grub

@rizalp
rizalp / sqlite3-notes.md
Last active March 21, 2023 12:22
[Building Sqlite3] Building latest Sqlite3 & Sqlitebrowser #sqlite3 #sqlitebrowser #ubuntu22.04

SQLite 3 Notes

Some notes when working with SQLite 3

SQLite 3 Compile Time Options And Pragma

SQLite has multiple build flag and pragmas that can be used to enable / disable certain functionality. Due to this, it's important to remember if certain functionality exist on your target servers

@rizalp
rizalp / phpbuild.md
Last active March 21, 2023 11:23
[Build PHP 8] Minimal Build PHP 8.2.4, linked with sqlite3 from source on Ubuntu 22.04 And Macos #php #sqlite3 #ubuntu22.04
@rizalp
rizalp / JavaScript: String.js
Last active July 2, 2022 05:29
JavaScript: String #JavaScript #string
var a = 9 + "7"; // = "97, string"
var b = "7" + 9; // = "79 string"
var fooInt = parseInt("34s12", 10); //34
fooInt = parseInt("hello", 10); //NaN
var fooFloat = parseFloat("3.14", 10); // 3.14
var words = "Cities of the Interior";
alert(words.split(" ")); //can only do split on string
// [Cities,of,the,Interior]
@rizalp
rizalp / JavaScript Sieve Of Atkin.js
Created May 3, 2013 11:49
return array of primes below limit using Sieve of Atkin Algorithm http://en.wikipedia.org/wiki/Sieve_of_Atkin #JavaScript #primes
function sieveOfAtkin(limit){
var limitSqrt = Math.sqrt(limit);
var sieve = [];
var n;
//prime start from 2, and 3
sieve[2] = true;
sieve[3] = true;
for (var x = 1; x <= limitSqrt; x++) {
@rizalp
rizalp / JavaScript: Boolean, If, Switch, Loop.js
Last active February 23, 2022 20:49
JavaScript: Control Structure: Boolean, If, Switch, Loop #JavaScript #loop #control #boolean
var foo = 5 == 6; // false
foo = "6" == 6; // true. Because the number 6 are first converted into a string
foo = "6" === 6; // false. It will also check equality of data type. Always use this operator
/*
&& (AND)
|| (OR)
! (NOT)
*/
@rizalp
rizalp / debug-symfony-phpstorm.md
Last active November 5, 2021 03:57
[Debugging Symfony Controller Using PHPStorm] step by step guide on how to do debugging on PHPStorm using Xdebug #symfony #xdebug #phpstorm #php

Debugging Symfony Controller Using PHPStorm

In order to debug symfony or php apps that uses front end controller approach, you need to have several things:

  • Configure Xdebug. I prefer to use the On-Demand mode, but beware that it's only applicable to cli scripts / code coverage reports. Make sure that you set the xdebug.mode=debug and xdebug.idekey=PHPSTORM. This will be usefull in case you need to Debugging Symfony commands.

debug-symfony-phpstorm-1

  • To debug incoming http request, you need to have a webserver running configuration. We'll use the PHP Built-in Web Server as it's sufficient for our purpose. Click Run > Edit Configurations > Add New Configuration > PHP Built-in We