Skip to content

Instantly share code, notes, and snippets.

View xntric78's full-sized avatar

Christopher M Pieper xntric78

View GitHub Profile
@guenter
guenter / mysql_commands_i_always_forget.sql
Created September 1, 2010 15:58
MySQL commands I forget all the time
-- Reset the query cache
RESET QUERY CACHE;
-- Closes all open tables, forces all tables in use to be closed, and flushes the query cache.
FLUSH TABLES;
-- Show character set in use by client, server, etc.
SHOW VARIABLES LIKE 'character_set%';
@guenter
guenter / move_to_rds.rb
Created November 11, 2010 02:14
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
@nberardi
nberardi / IObjectContext.cs
Created November 17, 2010 23:25
Code for my post on Repository Pattern for Entity Framework: http://coderjournal.com/2010/11/entity-framework-repository-pattern/
public interface IObjectContext : IDisposable
{
ObjectContextOptions ContextOptions { get; }
TEntity CreateObject<TEntity>() where TEntity : class;
IObjectSet<TEntity> CreateObjectSet<TEntity>() where TEntity : class;
int SaveChanges();
}
@dougnukem
dougnukem / BlockingQueue.java
Created September 25, 2011 23:32
Example Threadsafe BlockingQueue implementation in Java
public class BlockingQueue implements Queue {
private java.util.Queue queue = new java.util.LinkedList();
/**
* Make a blocking Dequeue call so that we'll only return when the queue has
* something on it, otherwise we'll wait until something is put on it.
*
* @returns This will return null if the thread wait() call is interrupted.
*/
@danielholmstrom
danielholmstrom / fix_double_encoded_utf8.example.sql
Created October 5, 2011 10:53
Fix double encoded UTF-8 in mysql with an SQL-query.
-- Example of how to fix double encoded UTF-8 in mysql with a single mysql query.
-- This example assumes that the data has been inserted with NAMES=latin1.
--
-- XXX: Do not rely on this to work without testing it. XXX
--
-- XXX: If this is run on a column with a UNIQUE index and the COLLATE is
-- case-insensitive this might fail. The reason for this is that double-encoded
-- upper and lower case chars are considered different but when encoded correctly
-- they will be considered the same.
@calo81
calo81 / LoggerFilter
Created March 18, 2012 12:48
Filter for reading and logging HttpServletRequest body, and resetting the input stream
package com.paddypower.financials.market.management.rest.logging;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@kamermans
kamermans / jmeter-server.sh
Last active December 5, 2018 08:01
Apache Jmeter Server init script for Ubuntu/Debian (tested on jmeter 2.6 and 2.7)
#!/bin/sh
### BEGIN INIT INFO
# Provides: jmeter-server
# Required-Start: $syslog $local_fs
# Required-Stop: $syslog $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache JMeter Remote Server
# Description: Apache JMeter Remote Server runs JMeter tests issued from a remote server.
### END INIT INFO
@myhd
myhd / mount_afp_when_itunes_running.sh
Created September 7, 2012 11:46
Script to connect to an AFP server when iTunes is running
#!/bin/sh
# This script will connect to an AFP server when iTunes is running
# 2012-09-07
HOST="hostname" # AFP server, e.g. server.local or 192.168.1.94 or…
USER="your_user_name" # for connection to AFP server
PASS="your_password" # for connection to AFP server
VOLUMENAME="your_volume_name" # name of volume to be mounted, typically username on AFP server.
@fabito
fabito / jenkins_nginx_ci.template.json
Created November 9, 2012 22:47
AWS Cloudformation template which creates a server based on Amazon Linux and automatically installs jenkins with nginx (working as a reverse proxy).
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation template to deploy jenkins/nginx.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
@karlcow
karlcow / emlx.py
Last active July 3, 2022 09:00
Parsing emlx files on Mac OS X. Apple Proprietary Storage Format for emails.
#!/usr/bin/env python
# encoding: utf-8
"""emlx.py
Class to parse email stored with Apple proprietary emlx format
Created by Karl Dubost on 2013-03-30
Inspired by Rui Carmo — https://the.taoofmac.com/space/blog/2008/03/03/2211
MIT License"""