Skip to content

Instantly share code, notes, and snippets.

Avatar

Adjetey Sowah thesowah

View GitHub Profile
View index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

View ig_downloader.rb
require 'restclient'
require 'json'
require 'digest'
class IGDownloader
def initialize(output_path)
@base_output_path = output_path
end
@thesowah
thesowah / Regex for Notepad++
Last active Aug 29, 2015
Fixes error in parsing XML to excel worksheet [ASP.NET C#]
View Regex for Notepad++
Using Notepad++ search and replac all the illegal characters in XML file
//#1 All cells with whitespace and chars like '&' but start with alphabets
Find: <Data ss:Type="String">([a-zA-Z]+(.+))</Data>
Replace: <Data ss:Type="String"><![CDATA[$1]]></Data>
//#2 All empty cells
Find: <Data ss:Type="String">*</Data>
Replace: <Data ss:Type="String"><![CDATA[-]]></Data>
View simple-git-branching-model.md

a simple git branching model

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@thesowah
thesowah / feed.xml
Created Jun 24, 2014
Jekyll Template for Atom, RSS feed. Template leaves HTML entities like &mdash; intact in XML + XSLT
View feed.xml
---
layout: nil
title : Atom Feed
---
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [<!ENTITY mdash "&#x2014;">]>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text" xml:lang="en">{{site.name}}</title>
<link type="application/atom+xml" href="{{site.url}}/feed.xml" rel="self"/>
<link type="text/html" href="{{site.url}}" rel="alternate"/>
@thesowah
thesowah / utility.rb
Created Jun 23, 2014
Utility script for Afridevcmty
View utility.rb
# This utility class is help gather data while avoiding
# Github's seach restriction of 1,000 results
# and traverse through the results using Link headers
# FYI: Our results is about 2700
require 'rest_client'
require 'json'
class Utility
@url = "https://api.github.com/search/users"
@thesowah
thesowah / plh.rb
Last active Jul 30, 2021
Parse link headers from Github API in Ruby
View plh.rb
require 'rest_client'
class Plh
def self.parse_link_header(url, params={})
response = RestClient.get url, params
links = Hash.new
parts = response.headers[:link].split(',')
# Parse each part into a named link
parts.each do |part, index|
@thesowah
thesowah / brace-effect
Created Mar 19, 2014
CSS tweak for open braces effect on HTML links
View brace-effect
/*****************************************************************************/
/* Links
/*****************************************************************************/
a {
color: black !important;
text-decoration: none !important;
cursor: pointer;
}
.post a {
border-bottom: 1px dotted #b3b3b1;
@thesowah
thesowah / relationship.orm.yml
Created Dec 10, 2013
One-to-one && One-to-many Object relationships (YAML configuration to auto-entity generation in Symfony2)
View relationship.orm.yml
# one-to-one, bidirectional
Customer:
oneToOne:
cart:
targetEntity: Cart
mappedBy: customer
Cart:
oneToOne:
customer:
targetEntity: Customer
View Person
<?php
//...
class Person
{
/* @var \Doctrine\Common\Collections\Collection */
private $talents
/* @var string */
private $gender