Skip to content

Instantly share code, notes, and snippets.

View cubapp's full-sized avatar

Jakub Urbanec cubapp

View GitHub Profile
@cubapp
cubapp / adjust-2-sea-pressure.py
Last active February 28, 2024 20:22
Python: How to get the adjusted-to-sea level barometric pressure from actual pressure, temperature and height above the sea level
# Actual atmospheric pressure in hPa
aap = 990
# Actual temperature in Celsius
atc = 10
# Height above sea level
hasl = 500
# Adjusted-to-the-sea barometric pressure
a2ts = aap + ((aap * 9.80665 * hasl)/(287 * (273 + atc + (hasl/400))))

Keybase proof

I hereby claim:

  • I am cubapp on github.
  • I am cuba (https://keybase.io/cuba) on keybase.
  • I have a public key ASBOrgm7hOdzr7GE_phGhxg4w3QKKcG6TG5Tn4i7aqd7Vgo

To claim this, I am signing this object:

@cubapp
cubapp / fizzbuzz.c
Created August 28, 2017 08:51
FizzBuZZ the C way - inspired by http://codepad.org/fizzbuzz
#include <stdio.h>
int main(void)
{
int i;
for(i=1; i<=100; i++)
(i%15)?(i%5)?(i%3)?printf("%d\n",i):printf("Fizz\n"):printf("Buzz\n"):printf("FizzBuzz\n");
return 0;
}
@cubapp
cubapp / fizzbuzz-ugly.c
Created August 28, 2017 09:00
The FizzBuzz.c the ugly way ...
#include <stdio.h>
void main(void){for(int i=0; i<=99; (++i%15)?(i%5)?(i%3)?printf("%d\n",i):printf("Fizz\n"):printf("Buzz\n"):printf("FizzBuzz\n"));}
@cubapp
cubapp / last5.c
Created January 16, 2018 07:50
Last 5 - get the last 5 characters from each line of a text file. From http://www.thelinuxrain.com/articles/bash-drivers-start-your-engines
#include <stdio.h>
#include <stdlib.h>
// from http://www.thelinuxrain.com/articles/bash-drivers-start-your-engines
// C version is about 2-4 times faster than perl version.
int main (int argc, char *argv[])
{
if (argc != 2){
printf("Usage: %s filename\n", argv[0]);
@cubapp
cubapp / adb-cast.sh
Created March 12, 2019 11:03
ADB way to cast screen from Android device to ffplay
adb devices
echo "Wait at least 10secs and use the Android screen"
adb shell screenrecord --output-format=h264 - | ffplay -probesize 1M -
@cubapp
cubapp / gist:dec68ea01655ed85e3cda84a4b5d56ae
Created September 18, 2019 12:50
Generate MD5 hash password with given salt
python -c "import random,string,crypt; not_so_randomsalt = 'synergy';
print crypt.crypt('', '\$1\$%s\$' % not_so_randomsalt)"
$1$synergy$O31nVEgYyKUdmjDRPUq8p.
@cubapp
cubapp / SHA256-password-hash.py
Created September 18, 2019 12:53
Generate SHA-512 password hash
python -c "import random,string,crypt;
randomsalt = ''.join(random.sample(string.ascii_letters,8));
print crypt.crypt('MySecretPassword', '\$6\$%s\$' % randomsalt)"
# $6$glmhpDPn$TnHWDtgh9ATjfUfEGUPoiFq1wATR0aHmDtDWaDOZWJmtDVsgsqmMriUQNcdV2pR1kA6tYQTIfMOYubdgBStEx.
@cubapp
cubapp / howto-migratePSTintoThunderbird.txt
Created September 10, 2020 06:12
Migrate from Outlook PST to Thunderbird
Terminal:
sudo apt install pst-utils
mkdir migrated-emails
readpst -o ./migrated-emails -M -u -w -e -b outlook.pst
Thunderbird:
1. install "ImportExportTools NG" add on
2. make new folder "MigratedEmails" in Thunderbird - preferably in "Lofal Folders"
3. right click on MigratedEmails folder -> ImportExportTools NG
-> import all messages from a directory
@cubapp
cubapp / dobble.c
Last active September 23, 2020 05:25
Dobble game card generator.
#include <stdio.h>
#include <stdlib.h>
// Dobblo generator
// Here is a C code inspired from @karinka's answer with a different arrangement of symbols.
// https://math.stackexchange.com/questions/1303497/what-is-the-algorithm-to-generate-the-cards-in-the-game-dobble-known-as-spo
//
// It works for n being a prime number (2, 3, 5, 7, 11, 13, 17, ...).
//
// Number of symbols in a given card = n+1
// Total number of cards = n^2 + n + 1