Skip to content

Instantly share code, notes, and snippets.

@ahamid
ahamid / transfer.sh
Created December 18, 2011 22:34
mirror unfuddle repo to bitbucket
#!/bin/sh
ufacct=$1
bbacct=$ufacct
uf=$2
bb=${3:-$uf}
echo "Cloning Unfuddle repo: $ufacct:$uf"
git clone --mirror git@$ufacct.unfuddle.com:$ufacct/$uf.git
cd $uf.git
@ahamid
ahamid / gist:1665057
Created January 23, 2012 19:25
selectively adding hunk
[aaron@msi-cr620 workspace]$ cd hunk-test/
[aaron@msi-cr620 hunk-test]$ git init .
Initialized empty Git repository in /home/aaron/workspace/hunk-test/.git/
[aaron@msi-cr620 hunk-test]$ git branch
[aaron@msi-cr620 hunk-test]$ git branch -v
[aaron@msi-cr620 hunk-test]$ git status
# On branch master
#
# Initial commit
#
@ahamid
ahamid / restorecon.rb
Created June 27, 2012 22:30
chef restorecon helper
libraries/restorecon.rb
def restorecon_cmd(path)
%Q(restorecon "#{path}")
end
# restores selinux label for path
def restorecon(path)
execute restorecon_cmd(path) do
action :nothing
@ahamid
ahamid / replace.go
Created July 4, 2012 05:45
whole file regexp replacement in go
package main
import (
"regexp"
"os"
"io/ioutil"
)
func main() {
regexp, _ := regexp.Compile(os.Args[1])
@ahamid
ahamid / gist:3626285
Created September 4, 2012 20:49
Comfortable Mexican Sofa render CMS content as partial
# config/initializers/comfortable_mexican_sofa.rb
require 'cms_renderer'
# lib/cms_renderer.rb
require 'action_view/renderer/renderer'
require 'action_view/renderer/template_renderer'
class CMSRenderer < ActionView::TemplateRenderer
@ahamid
ahamid / gist:3764001
Created September 21, 2012 21:25
closure compiler / rhino - find source of RValue
/**
* Copyright 2012 Incandescent Software LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ahamid
ahamid / gist:3777562
Created September 24, 2012 18:44
google closure compiler, type in IIFE
/**
* @typedef {Object}
*/
var vendor = Vendor = {};
///**
// * @constructor
// */
//Vendor.VendorType = function() {};
@ahamid
ahamid / spec_helper.rb
Created July 29, 2012 05:10
benchmark + profile RSpec test
require 'ruby-prof'
require 'benchmark'
module BenchmarkHelpers
PROFILE_OUTPUT_DIR = "profiling"
def self.safe_filename(name)
name.gsub(" ", "_")
end
def self.example_output_target_file!(example)
@ahamid
ahamid / gist:1432255
Created December 5, 2011 04:07
CMake linker flags
cmake_minimum_required (VERSION 2.6)
set(FILL_UTIL "${PROJECT_SOURCE_DIR}/utils/fill")
set(SIZE_UTIL "${PROJECT_SOURCE_DIR}/arch/i386/size.sh")
set(cpu_objects main.c task.c pgrequest.c descriptor.c thread.c tss.c interrupt.c paging.c memory.c caps.c permissions.c ttrace.c)
set(prt_objects print.c)
set(assembly_src cpu-asm.s arch/i386/kernel/int.s arch/i386/kernel/pic.s arch/i386/kernel/stack_winding.s arch/i386/kernel/state_switch.s arch/i386/kernel/syscall-gates.s arch/i386/kernel/vga.s)
#add_custom_command(OUTPUT assembly.o COMMAND ${AS} ${AS_FLAGS} -o assembly.o ${assembly_src})
@ahamid
ahamid / Dockerfile
Created July 17, 2019 21:56
Docker tutorial part3
# Use an official Python runtime as a parent image
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt