Skip to content

Instantly share code, notes, and snippets.

@CitizenOfRome
CitizenOfRome / purge-unused-kernels-grub.sh
Created January 27, 2018 03:20
To overcome the `gzip: stdout: No space left on device` /boot full errors on ubuntu
sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -vuname -r| while read -r line; do sudo apt-get -y purge $line;done;sudo apt-get autoremove; sudo update-grub
@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 -----
# 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 / Doer training lv 2 .md
Last active May 25, 2016 04:58
Doer training lv 2 - after the trainee Doer picks up most of the basics, via tutorials and on-the-job tasks

Doer training lv 2

Practise

You'll need your basics in HTML, CSS, JavaSacript, jQuery and integrating plugins to be at a solid level, which is only possible through practise I'd suggest putting all your free time on cloning pages or sections of popular web-applications on your own - starting with simple stuff like the home page on facebook, or the google search home page at a pixel-perfect level and then moving to things like the chat feature on facebook with Laravel and AngularJS, etc The harder you work on yourself and your skills now, the easier it'll get down the line

Aim for simple stuff like the FB and Google Home pages, moving on to LinkedIn profile page with in-place editing with AngularJS/jQuery I don't particularly care about the final results here as much as the effort you put in and the demonstrable learning you get out of it

@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,
function brainLuck(code, input){
var dp = 0, output = [], value = 0, data='', ip=0, braceCount = 0;
for(var i=0, l= code.length; i < l; i++) {
switch(code[i]){
case '>':
dp++;
if(dp >= data.length) {
data += String.fromCharCode(0);
}
break;
@CitizenOfRome
CitizenOfRome / combine.py
Created September 14, 2013 06:46
A python script to combine files, given the file path or URL
def file_get_contents(filename):
print("Reading file: " + filename)
with open(filename) as f:
return f.read()
import urllib2
def url_get_contents(url):
print("Reading URL: " + url)
return urllib2.urlopen(url).read()