Skip to content

Instantly share code, notes, and snippets.

Octavian Neamtu oneamtu

Block or report user

Report or block oneamtu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:99106fa4ee856878ad10
def mapper(a)
b =! { |x| x.nil? }
c = [nil]
expect(mapper(c)).to eq([true]) # => true
expect(mapper(c)).to eq([true]) # => false
oneamtu / debugincludes.cmake
Created Jun 16, 2011
quick and dirty way of seeing what folders cmake is including for a certain project
View debugincludes.cmake
#embed this in your code
get_directory_property(includes INCLUDE_DIRECTORIES)
foreach(arg ${includes})
set(print_string "${print_string}\n${arg}")
endforeach(arg ${includes})
message(FATAL_ERROR ${print_string})
oneamtu / ip_discover.cpp
Created Jun 17, 2011
Fastest way to obtain IP address of current host
View ip_discover.cpp
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <time.h>
#include <sys/time.h>
oneamtu / gist:1053256
Created Jun 29, 2011
a roundabout kill command using a call to system()
View gist:1053256
FILE *output = popen("su -c 'cat /var/lock/naoqi.lock'", "r");
char buffer[256];
fgets(buffer, sizeof(buffer), output);
char command[256] = "kill -9 ";
strcat(command, buffer);
printf("command %s\n", command);
oneamtu / deploy.rb
Created Sep 10, 2012 — forked from uhlenbrock/deploy.rb
Precompile assets locally for Capistrano deploy
View deploy.rb
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
oneamtu / copy_and_rename.awk
Created Feb 15, 2013
A simple script to copy a file with a path matching a pattern and then optionally replace that pattern with a different string in the file name
View copy_and_rename.awk
#!/usr/bin/awk -f
# A simple script to copy a file with a path matching a pattern
# and then optionally replace that pattern with a different string
# in the file name
# Usage: ./cp_and_rename.awk -v subject=[foo] -v replacement=[bar] \
# -v dest_prefix=[baz]
# E.g.
oneamtu / one_line.rb
Created Mar 2, 2013
Eric's refactoring challenge
View one_line.rb
string.split('.').each_with_index.inject([""]){|a, i| a+[a[i[1]]+"."+i[0]]}.reject(&:empty?).map{|a| a[1..-1]}.join(" && ")
oneamtu / post-checkout
Last active Dec 15, 2015
post-checkout hook script to change database.yml config
View post-checkout
# This hook changes database name prefix in config/database.yml based on the branch
# being checked out. It expects the database name prefix to be on word followed
# by a dash.
# If the branch name has a dash, it will take the new database name prefix as the
# name of the branch before the first dash e.g. ihas-feature => ihas
# This allows multiple branches to use the same database.
# File checkouts are ignored. Checking out a remote branch or a different ref
View .editorconfig
# EditorConfig is awesome:
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
indent_style = space
tab_width = 2
charset = utf-8
oneamtu /
Last active May 24, 2019
set up docker persistent database instance for development
sudo docker pull percona:5.6
# To run the daemon
sudo docker run --restart unless-stopped --name percona-5.6 -p -v /data/mysql-5.6:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=$ROOT_MYSQL_PASSWORD -d percona:5.6
# To check/run a console
sudo docker run -it --link percona-5.6:mysql --rm percona sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -u$(echo $ROOT_MYSQL_USER) -p$(echo $ROOT_MYSQL_PASSWORD)'
# To start/stop
You can’t perform that action at this time.