Skip to content

Instantly share code, notes, and snippets.

View oz123's full-sized avatar
🎯
Focusing

Oz Tiram oz123

🎯
Focusing
View GitHub Profile
@oz123
oz123 / mnt-gentoo.sh
Created January 17, 2016 14:28
Automatically mount gentoo partition for working on the handbook
# use this script to initialize work on gentoo install
# this is the base for fully installing automatically
# we still have lot's of work to do ...
# mount everything needed for a working chroot
function mount_all(){
mount $1 /mnt/gentoo
mount -t proc proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
@oz123
oz123 / gist:c8d69d0121d5c8acdf82
Created November 4, 2015 09:11
weired output from salt
vagrant@saltmaster:/srv/salt$ vim common/py_packages.sls # edit and mark django for downgrade
vagrant@saltmaster:/srv/salt$ sudo salt minion1 state.sls common.py_packages
minion1:
----------
ID: install_django == 1.8.0
Function: pip.installed
Name: django == 1.8.0
Result: True
Comment: All packages were successfully installed
Started: 08:58:20.748303
@oz123
oz123 / state.sls
Last active November 2, 2015 12:58
snippet from my state
{% if grains['os'] == 'CentOS' %}
{% set piploc = '/usr/bin/pip' %}
{% elif grains['os'] == 'Ubuntu' %}
{% set piploc = '/usr/local/bin/pip' %}
{% endif %}
{% if not salt['file.file_exists'] == piploc %}
@oz123
oz123 / Makefile
Created February 26, 2015 17:47
A rudimentary task queue using multiprocessing in Python
#SHELL = bash -xv
.PHONY: create_all_tasks, quick, slow, task_one, task_two show_tree, sleep
slow:
$(shell echo "this task will hang around;15" > 4.task)
quick:
$(shell echo "this task will finish quickly;5" > 3.task)
@oz123
oz123 / build_if_new_version.sh
Last active August 29, 2015 14:13
Build sphinx docs from multiple branches on change - kind of like read the docs for the poor
#!/bin/sh
CONFIG_FILE=$1
source $CONFIG_FILE
cd $PROJECT_DIR
export PATH=/usr/local/bin:$PATH
@oz123
oz123 / array_access
Created December 11, 2014 23:10
accessing array elements ...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* demonstrate pass by reference of an array of integers*/
void resize( int **p, int size ) {
free( *p );
*p = (int*) malloc( size * sizeof(int) );
int tocpy[]= {8};
@oz123
oz123 / array_pass_by_ref.c
Created December 11, 2014 13:55
Modify arrays inside functions in C. This subject is always tricky and I tend to forget, so here is a not to self.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* demonstrate pass by reference of an array of integers*/
void resize( int **p, int size ) {
free( *p );
*p = (int*) malloc( size * sizeof(int) );
int tocpy[]= {8};
@oz123
oz123 / test_number.c
Created December 3, 2014 22:50
Detect if a string is an integer or a double number
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
char* to_convert = argv[1];
char* p = NULL;
@oz123
oz123 / Cronjob_and_Explanation
Created December 2, 2014 15:55
I was ask to collect all logs from different host to a central place. I was also asked to implement this with rsync. So here is what I came up with:
cronjob:
========
* 1 * * * rsync -e 'ssh -v -i .ssh/log_coll_id_rsa logcol@server' -aP /var/log/mongodb/*.s server:.
### There results:
On the server called server you will see in the home directory of the ssh user you created a directory with the log files for each host
you installed the ssh key, the script and the cron job.
ls ~
@oz123
oz123 / ephoc2gmt.c
Created December 2, 2014 08:29
A small reminder to self how to convert seconds since the epoch to GM time.
#define _XOPEN_SOURCE
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
// in main()
int