Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python3
""" Cleaning script based on .gitignore file, the 'find' and 'rm' command.
It removes files with .gitignore pattern.
This script reads the .gitignore file, parses the patterns found there to a
shell remove command and then executes it.
- With the 'dirs' option it also removes directories.
- With the 'debug' option it just prints the command it would execute and exits.
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
#!/bin/sh
# Pre-commit hook that crushes PNG files in order to reduce their size.
if ! which -s pngcrush
then
echo "Please install pngcrush to reduce png images size before commit"
exit 1;
fi
for file in `git diff --cached --name-only | grep ".png\$"`
@pudney
pudney / _mvn
Created June 9, 2010 17:11
Zsh Completion Function for Maven
#compdef mvn
_mvn_targets () {
local -a commands
commands=('jetty\:run:Run Jetty from the current context.' 'validate:validate the project is correct and all necessary information is available' 'compile:compile the source code of the project' 'test:test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed' 'package:take the compiled code and package it in its distributable format, such as a JAR.' 'integration-test:process and deploy the package if necessary into an environment where integration tests can be run' 'verify:run any checks to verify the package is valid and meets quality criteria' 'install:install the package into the local repository, for use as a dependency in other projects locally' 'deploy:done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.' 'clean:remove all files generated by the previous build')
_describe -t commands
// Newbie programmer
int factorial_newbie(int n) {
if (n == 0) {
return 1
} else {
return n * factorial_newbie(n - 1)
}
}
println factorial_newbie(6)
@fmela
fmela / stacktrace.cxx
Last active September 22, 2023 10:58
A C++ function that produces a stack backtrace with demangled function & method names.
/*
* Copyright (c) 2009-2017, Farooq Mela
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
#!/bin/zsh
# Copyleft 2010 paradoxxxzero All wrongs reserved
# With contribution from James Ahlborn
# https://gist.github.com/752727
# Fork of https://gist.github.com/586698 by nicoulaj / dingram / roylzuo ...
# From http://www.zsh.org/mla/users/2010/msg00692.html
# Token types styles.
# See http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135
@GregMefford
GregMefford / setup-statsd-centos.sh
Last active April 10, 2022 15:31 — forked from collegeman/setup-statsd.sh
Install Graphite and StatsD on CentOS (updated for 6.4 x86_64)
# First do a fresh install of CentOS 5.7 i386, server configuration (no GUI)
# This should be performed as root since it's going to be installing a bunch of stuff
# --- Update things to make sure we have the latest patches ---
# Add EPEL so we can get reasonably recent packages
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# --- Install all the packages --- #
yum -y install python-whisper python-carbon graphite-web python-memcached python-ldap httpd memcached
@jcartledge
jcartledge / ~_.config_terminator_config
Created April 27, 2011 04:31
terminator config solarized
[global_config]
title_transmit_bg_color = "#839496"
title_inactive_fg_color = "#93a1a1"
title_transmit_fg_color = "#eee8d5"
title_inactive_bg_color = "#586e75"
[keybindings]
[profiles]
[[default]]
palette = "#073642:#d30102:#859900:#b58900:#6c71c4:#d33682:#2aa198:#839496:#586e75:#cb4b16:#859900:#b58900:#268bd2:#d33682:#2aa198:#93a1a1"
login_shell = True
@tuor713
tuor713 / ObjectSizer
Created July 21, 2011 19:16
Calculating total size of Java object graph
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.IdentityHashMap;
public class ObjectSizer {
private static Instrumentation instrumentation;