Skip to content

Instantly share code, notes, and snippets.

View CodeByLine's full-sized avatar

Yumei Leventhal CodeByLine

View GitHub Profile
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@niksumeiko
niksumeiko / git.migrate
Last active November 10, 2024 18:26
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@cdils
cdils / custom_header.php
Created March 7, 2014 22:31
Code hijack from Genesis Framework functions/header.php genesis_do_header function.
<?php //ditch this entire line
remove_action( 'genesis_header', 'genesis_do_header' );
remove_action( 'genesis_header', 'brainfartin_do_header' );
function brainfartin_do_header() {
global $wp_registered_sidebars;
genesis_markup( array(
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active September 15, 2024 20:33
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@thebucknerlife
thebucknerlife / deploying_rails_to_heroku.md
Created October 20, 2014 23:41
A Beginners Guide to Deploying a Rails App on Heroku

Deploying to Heroku

This guide is for a first-time Rails developer to deploy their app to Heroku, a popular web-hosting service with strong Rails support. This guide assumes you already have a Heroku account and have installed the Heroku Toolbelt.

Create Your App and Setup Heroku with Git

  1. Make sure you've setup an SSH key for Heroku. Follow this simple guide to create an SSH key and send it to Heroku if needed: Heroku: Managing Your SSH Keys
  2. Navigate into the folder for your Rails app.
@SusanRamsey
SusanRamsey / 1152 Grid System
Created March 14, 2016 17:53
This is the page for the 1152 Grid System
<div style="float:left;margin-right:4.166666666%;width:65.277777777%">
<p style="background-color: #1e1e1e;color: #fff;padding: 24px 0;text-align: center">Content (752px)</p>
</div>
<div style="float:left;width:30.555555555%">
<p style="background-color: #1e1e1e;color: #fff;padding: 24px 0;text-align: center">Sidebar (352px)</p>
</div>
<div class="clear"></div>
<div style="float:left;margin-right:4.166666666%;width:30.555555555%">
@Brachamul
Brachamul / command
Created December 26, 2016 11:40
Set an existing user to superuser using Django shell
python manage.py shell
@wynand1004
wynand1004 / top_secret_decoder.py
Created October 10, 2017 00:05
Top Secret Decoder Practice
# Top secret decoder
# The CIA has discovered a plot against a major city
# SIGINT has intercepted a message with the location and date of the attack
# Unfortunately, the message is encoded.
# Due to your awesome Python skills, you have been hired to decode the message
# A double agent has provided the encoding scheme which is as follows:
# All numbers need to be changed to spaces
# All capital letters should be changed to *
# The lowercase letter q is equal to \n
# All other lowercase letters should be ignored.
@wynand1004
wynand1004 / RPS_ASCII_Art.py
Created October 15, 2017 04:05
Rock, Paper, Scissors ASCII Art
# Rock Paper Scissors ASCII Art
# Rock
print("""
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
@wynand1004
wynand1004 / rock_paper_scissors.py
Last active December 30, 2017 03:49
Basic Rock Paper Scissors Program (No Loop)
#Janken with Loop Assignment Example by Christian Thompson
#Uses Random numbers 1-3 to represent Rock, Paper, Scissors
#Initialize
import os
import random
import time
#Declare variables