Skip to content

Instantly share code, notes, and snippets.

View marianposaceanu's full-sized avatar

Posăceanu Marian marianposaceanu

View GitHub Profile
@marianposaceanu
marianposaceanu / linux_performance.md
Last active January 30, 2024 06:47
Linux simple performance tweaks

Linux simple performance tweaks

Change the I/O Scheduler

Open $ vim /etc/default/grub then add elevator=noop next to GRUB_CMDLINE_LINUX_DEFAULT. Run $ update-grub and $ cat /sys/block/sda/queue/scheduler to be sure that noop is being used:

$ vim /etc/default/grub
$ update-grub
$ cat /sys/block/sda/queue/scheduler

[noop] deadline cfq

How to use top_history.sh

Overview

top_history.sh is a script that displays the top 10 most used commands from the zsh history. It generates a bar chart using Gnuplot to visualize the command frequencies.

Requirements

Before using top_history.sh, make sure you have the following requirements installed on your system:

  1. Zsh Shell: This script is designed for use with the Zsh shell. Ensure you have Zsh installed as your default shell.

Comparison of setting a key to Redis

note: Redis is running locally with a maximum of 10K connections

 set LZ4 + MessagePack:    401.7 i/s
           set Marshal:    232.3 i/s - 1.73x  slower
     set LZ4 + Marshal:    176.4 i/s - 2.28x  slower
              set to_s:    141.5 i/s - 2.84x  slower
 set Snappy + Marshal: 92.6 i/s - 4.34x slower
@marianposaceanu
marianposaceanu / linux_fun.md
Last active January 29, 2023 20:31
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
# A simple way to measure start-up time from inside Java application
# credits:
# - https://stackoverflow.com/questions/39321345/how-do-i-measure-jvm-startup-time
#
# How to run:
#
# 0. install JRuby (brew, rvm, etc.) e.g. `rvm install jruby-9.2.11.1`
# 1. download this script
# 2. in the shell run `for i in {1..10}; do ruby jruby_start_up.rb; done | awk '{ total += $1; count++ } END { print total/count }'`
# => 1673.9

Typographic glyphs

via

Shortcuts and proper use

name glyph mac other description
curly single quotes ‘ ’ Option+] and Shift+Option+] ALT-0145 and ALT-0146 hover for description
curly double quotes “ ” Option+[ and Shift+Option+[ ALT-0147 and ALT-0148 -
@marianposaceanu
marianposaceanu / disable.sh
Created December 31, 2019 00:04
Disable bunch of #$!@ in Catalina
#!/bin/bash
# IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it!
# IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS.
# This script needs to be run from the volume you wish to use.
# E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh
# WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars.
# Get active services: launchctl list | grep -v "\-\t0"
# Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents
@marianposaceanu
marianposaceanu / latency.md
Created May 31, 2012 10:18 — forked from jboner/latency.txt
Latency numbers every programmer should know

CPU

  • L1 cache reference 0.5 ns
  • Branch mispredict 5 ns (on a bad CPU architecture you're pretty much screwed)
  • L2 cache reference 7 ns
  • Mutex lock/unlock 25 ns
  • Main memory reference 100 ns
  • Compress 1K bytes with Zippy 3,000 ns
  • Send 2K bytes over 1 Gbps network 20,000 ns
  • Read 1 MB sequentially from memory 250,000 ns
@marianposaceanu
marianposaceanu / 00_initial_info_and_credits.md
Last active March 27, 2020 15:51
Setting up Unicorn to run via init.d

Unicorn via init.d

You have your Rails Apps with specific Gemsets in RVM.

The following commands creates a wrapped unicorn_rails bin. Be sure to replace the variables and that you have unicorn in your bundle.

rvmsudo rvm wrapper [RUBY VERSION]@[GEMSET] [GEMSET] unicorn_rails

Now you have a /usr/local/rvm/bin/[GEMSET]_unicorn_rails