Skip to content

Instantly share code, notes, and snippets.

@CitizenOfRome
CitizenOfRome / .bashrc
Created December 13, 2017 12:40
Setup ssh-agent to help manage your ssh auth in git, etc
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
@CitizenOfRome
CitizenOfRome / easy_git_and_ssh_based_deployer.sh
Last active November 28, 2017 08:03
Easily deploy to your server via SSH and GIT with a single BASH file
#!/bin/bash
cd "`dirname $0`"
# The commit/deployment message
MESSAGE='Uh...'
[ -n "${1}" ] && MESSAGE=${1}
# ----- Part 1 - Prep the source/main repo -----
@mrkpatchaa
mrkpatchaa / git-export-changes-between-two-commits.md
Last active June 10, 2026 11:38
[Git command to export only changed files between two commits] #git

Use case : Imagine we have just created a project with composer create-project awesone-project (currently V0.2). 2 weeks later, there is a new release (V0.3). How to update your project ? Since composer update only updates the project dependencies, it is not what we are looking for. Composer doesn't know about awesome-project since it's not in our composer.json.

After trying many git solutions, I've come to this :

git archive --output=changes.zip HEAD $(git diff --name-only SHA1 SHA2 --diff-filter=ACMRTUXB)

This command will check for changes between the two commits and ignore deleted files.

# Initial setup guide: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
adduser user
usermod -aG sudo user
su -l user
ssh-keygen
sudo vi /etc/ssh/sshd_config
@CitizenOfRome
CitizenOfRome / git.md
Last active February 11, 2020 11:32
Getting started with Git

Please install the command-line GIT tool from https://git-scm.com/ and run ssh-keygen in the newly setup git commandline tool / git-bash

Here are a few commands you'll be using often to interact with git, as a quick reference, keep them handy somewhere so that you can quickly get used to them:

  1. Run git config --global core.longpaths true after installing git to enable support for longpaths on windows which we use for some repos with legacy dependecies.

  2. git clone https://user@bitbucket.org/team/project.git - Downloads a copy of the website code for local use (Used only the first time).

  3. git add . -A && git commit -am "Your commit Message describing the changes you made" - Once you make changes, you can have git record them with this command; Make sure you add and commit for every significant change, so that you also have an additional backup

@CitizenOfRome
CitizenOfRome / clearOlderCookies.php
Created August 27, 2014 18:07
Clear cache and cookies if they are from an older version
<?php
define('APP_VERSION', '1.2.14');
if ($_COOKIE['APP_VERSION'] !== APP_VERSION) {
// Delete all cookies and invalidate cache if it is from an older version
if (isset($_SERVER['HTTP_COOKIE'])) {
// Unset cookies - http://stackoverflow.com/a/2310591/937891
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach ($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
@CitizenOfRome
CitizenOfRome / dg-with-locals.js
Last active August 29, 2015 14:02
AngularJS with-locals directive, used to rename local scope variables to create reusable modules with ng-include
'use strict';
// http://stackoverflow.com/a/17876761/937891
// <div dg-with-locals dg-with-locals-cars="allCars | onlyNew">{{locals.cars}}</div>
angular.module('adminApp')
.directive('dgWithLocals', ['$parse', '$rootScope',
function ($parse, $rootScope) {
return {
scope: true,
@claudiojs
claudiojs / phonegap_download_example.html
Last active August 29, 2015 13:56 — forked from nathanpc/phonegap_download_example.html
Downloading a file with phonegap.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
anonymous
anonymous / An-Anonymous-Pen.markdown
Created October 16, 2013 10:20
A Pen by Anonasaurus Rex.