This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Note: Default are good enough for most uses | |
| sudo cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount | |
| sudo systemctl enable tmp.mount | |
| sudo systemctl start tmp.mount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on this one: http://www.zedwood.com/article/cpp-is-valid-utf8-string-function | |
| bool utf8_check_is_valid(const char *str, int len) { | |
| int n; | |
| for (int i = 0; i < len; ++i) { | |
| unsigned char c = (unsigned char) str[i]; | |
| //if (c==0x09 || c==0x0a || c==0x0d || (0x20 <= c && c <= 0x7e) ) n = 0; // is_printable_ascii | |
| if (0x00 <= c && c <= 0x7f) { | |
| n=0; // 0bbbbbbb | |
| } else if ((c & 0xE0) == 0xC0) { | |
| n=1; // 110bbbbb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static std::string make_guid() { | |
| int integers[4] = { rand(), rand(), rand(), rand() }; | |
| std::string result(36, '\0'); | |
| sprintf(&result[0], "%08x-%04x-%04x-%04x-%04x%08x", | |
| integers[0], | |
| integers[1] >> 16, | |
| integers[1] & 0xffff, | |
| integers[2] >> 16, | |
| integers[2] & 0xffff, | |
| integers[3]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define DO_ITER 1 | |
| #define DO_REC 2 | |
| #define DO_DP 3 | |
| #define DO 3 | |
| int fibonacci(int n); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; NOT OPTIMIZED | |
| ; n * factorial(n - 1); | |
| mov eax,dword ptr [n] ; eax = n | |
| sub eax,1 ; eax = eax - 1 | |
| push eax ; push eax onto the stack | |
| call factorial ; call factorial with the argument pushed above | |
| add esp,4 ; restore stack pointer | |
| imul eax,dword ptr [n] ; final multiplication |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| DATE=$(date '+%s') | |
| INTERVAL=10 | |
| mongostat --json $INTERVAL > mongostat_$DATE.log & | |
| MONGOSTAT=$! | |
| mongotop --json $INTERVAL > mongotop_$DATE.log & | |
| MONGOTOP=$! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*jshint esversion: 6 */ | |
| var mongodb = require('mongodb'); | |
| var uri = 'mongodb://localhost:27017/test'; | |
| var Status = { | |
| GREEN : 'green', | |
| YELLOW: 'yellow', | |
| RED : 'red' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| root@neon:~# cryptsetup luksFormat -c aes-xts-plain64:sha512 -h sha512 /dev/sda3 | |
| WARNING! | |
| ======== | |
| This will overwrite data on /dev/sda3 irrevocably. | |
| Are you sure? (Type uppercase yes): YES | |
| Enter passphrase: | |
| Verify passphrase: | |
| root@neon:~# cryptsetup luksOpen /dev/sda3 sda3-crypt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # File: core-values-greeting.sh | |
| # Author: ichramm | |
| # Description: Prints a core value in ASCCI art | |
| # Usage: core-values-greeting.sh [core-value|login] | |
| # Params: | |
| # core-value: The core value to print , Accepted values: become,enjoy,more,strive,team,think,wow | |
| # Prints a random core value if not set, | |
| # Orints a greeting plus a random core value if it is set to 'login' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| pacman -Qmq | while read package; do | |
| cur_version=$(pacman -Qi $package | egrep 'Version *:' | sed 's/Version *: *//'); # fast | |
| aur_version=$(yaourt -Si $package | egrep 'Version *:' | sed 's/Version *: *//'); # slow | |
| if [ "$cur_version" = "$aur_version" ]; then | |
| echo -e "\e[0;32mUp to date: \e[0m$package"; | |
| else | |
| echo -e "\e[1;33mNeeds update: \e[0m$package \e[0;33m(installed: $cur_version, aur: $aur_version)\e[0m"; | |
| fi |