Skip to content

Instantly share code, notes, and snippets.

View Cvetomird91's full-sized avatar

Cvetomir Denchev Cvetomird91

  • Plovdiv, Bulgaria
View GitHub Profile
@dafrancis
dafrancis / color.h
Created November 14, 2011 21:29
"Zed's Awesome Debug Macros" from Exercise 20 of "Learn C the Hard Way" (http://c.learncodethehardway.org/). Now with added colours! (Yes I know I use "color" in the code)
#ifndef __color_h__
#define __color_h__
/*
* I got some of the colour codes (as well as having the idea of putting them in a macro) from here:
* http://stackoverflow.com/questions/3506504/c-code-changes-terminal-text-color-how-to-restore-defaults-linux
*/
#define RED "\e[31m"
#define GREEN "\e[32m"
@tsterker
tsterker / gist:2408855
Created April 17, 2012 20:40
[js] argument unpacking
// Taken from:
// http://readystate4.com/2008/08/17/javascript-argument-unpacking-converting-an-array-into-a-list-of-arguments/
var item1 = ['Jack', '39', 'Panda'];
function hi(name, age, type){
console.log('Hi ' + name + '! You are ' + age + ' and a ' + type + '!');
}
@alefteris
alefteris / smartgit.desktop
Created April 30, 2012 18:52
Smartgit desktop file for use with Ubuntu Unity launcher
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
StartupNotify=true
Name=Smartgit
Exec=env SMARTGIT_JAVA_HOME=/opt/apps/jre7/ /opt/apps/smartgit/bin/smartgit.sh
Icon=/opt/apps/smartgit/bin/smartgit-64.png
@stianeikeland
stianeikeland / broker.coffee
Created September 24, 2012 15:46
ZeroMQ broker (push/pull + pub/sub)
# Router / Central hub for home automation.
# Receives events and distributes via pub/sub
zmq = require 'zmq'
inputPort = 'tcp://*:8888'
outputPort = 'tcp://*:9999'
# Pull socket for incoming (push/pull), pub for outgoing (pub/sub)
input = zmq.socket 'pull'
@lifuzu
lifuzu / .gitconfig
Created March 11, 2014 17:09
Three levels of GIT config
# There are 3 levels of git config; project, global and system.
# project: Project configs are only available for the current project and stored in .git/config in the project's directory.
# global: Global configs are available for all projects for the current user and stored in ~/.gitconfig.
# system: System configs are available for all the users/projects and stored in /etc/gitconfig.
# Create a project specific config, you have to execute this under the project's directory.
$ git config user.name "John Doe"
# Create a global config
@nasirkhan
nasirkhan / doc_to_html.sh
Created April 11, 2014 18:16
convert .doc to .html using libreoffice command
# the following command will convert all the files to HTML which has the DOC extension.
find . -name "*.DOC" -type f -print0 |xargs -0 -I {} libreoffice --headless --convert-to html:HTML --outdir /home/nasir/output {}
@kipras
kipras / git-stash-push
Created June 13, 2014 10:37
git-stash-push
#!/bin/sh
#
# git-stash-push
# Push working tree onto the stash without modifying working tree.
# First argument (optional) is the stash message.
if [ -n "$1" ]; then
git update-ref -m "$1" refs/stash "$(git stash create \"$1\")"
else
HASH=`git stash create`
MESSAGE=`git log --no-walk --pretty="tformat:%-s" "$HASH"`
@foca
foca / 0_README.md
Last active May 10, 2023 20:55
A Makefile for developing a ruby gem

A Makefile for building ruby gems

This Makefile aids in developing a ruby gem. It's pretty opinionated to my workflow, but it might be useful to you, so here it goes.

  1. Assumes you use of [gs][gs] (or [gst][gst]) for managing gemsets.
  2. Assumes you use [dep][dep] for installing dependencies. Because fuck Bundler.
  3. Assumes the directory in which the source code is located is named after the gem. So basename $(dirname $(pwd)) would return foo
@jahe
jahe / gradle-cheatsheet.gradle
Last active December 8, 2022 07:22
Gradle Cheatsheet
// imports a couple of java tasks
apply plugin: "java"
// List available tasks in the shell
> gradle tasks
// A Closure that configures the sourceSets Task
// Sets the main folder as Source folder (where the compiler is looking up the .java files)
sourceSets {
main.java.srcDir "src/main"
@nsdiv
nsdiv / gist:9effb78e27ff6ca94381
Created November 7, 2015 00:37
Mock MongoDB when unit testing services with Spring Boot
If you are using Spring Boot with MongoDB, then a MongoDB connection is required even if you are unit testing a function.
Spring creates a connection to mongoDB during start up, because of Autowired beans in your code. This slows down your unit tests, and
also means your unit tests require access to the MongoDB server.
Here is what you need to do:
1. Mock the beans created by org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration:
@Bean
public MongoDbFactory mongoDbFactory(){
return null;
}