Skip to content

Instantly share code, notes, and snippets.

View jamesattard's full-sized avatar

James A. jamesattard

View GitHub Profile
╭─james@darktech ~
╰─$ sudo yum install bash -y
Resolving Dependencies
--> Running transaction check
---> Package bash.x86_64 0:4.2.47-3.fc20 will be updated
---> Package bash.x86_64 0:4.2.47-4.fc20 will be an update
--> Finished Dependency Resolution
..
..
Complete!
@jamesattard
jamesattard / skip_dup_error.sh
Last active August 29, 2015 14:14
MySQL Replication Skip "Duplicate Error"
#!/bin/bash
while [ `mysql -e "show slave status" | grep -c "Error_code: 1062"` -ge 1 ]; do
`mysql -e "SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE"`
echo -n "."; sleep 1
done
@jamesattard
jamesattard / gist:51240a9a60ca6bf9513e
Last active October 19, 2025 18:40
Fix Permissions and Refresh KExt cache
echo "Fixing ownership and permissions..."
chmod -R 755 /System/Library/Extensions/*
chown -R root:wheel /System/Library/Extensions/*
chown root:admin /
echo "Rebuilding kext cache..."
kextcache -system-prelinked-kernel
kextcache -system-caches
@jamesattard
jamesattard / hello.java
Created December 6, 2015 16:03
non-static method from static method
package com.example.helloworld;
public class HelloWorld
{
public void sayHelloFromFile(){
FileResource resource = new FileResource("hello_unicode.txt");
for(String line : resource.lines()){
System.out.println(line);
}
@jamesattard
jamesattard / summarise.sh
Created March 14, 2016 18:03
summarise r2d counts
#!/bin/bash
sum=0
[ $# -ge 1 -a -f "$1" ] && input="$1"
cat $input | grep -o '[0-9]*' | while IFS= read -r line
do
sum=$((sum + line))
echo $sum >> /tmp/sum.tmp
@jamesattard
jamesattard / BackgroundTask.h
Created April 21, 2016 19:15 — forked from liamzebedee/BackgroundTask.h
Attempts at implementing background tasks in React Native iOS
//
// BackgroundTask.h
// tomtrack
//
// Created by Liam Edwards-Playne on 13/02/2016.
//
#import "RCTBridgeModule.h"
@interface BackgroundTask : NSObject <RCTBridgeModule>
@jamesattard
jamesattard / mutation.js
Created December 29, 2016 17:35
mutation.js Free Code Camp
function mutation(arr) {
var checkArr = arr[1].toLowerCase().split("");
for (var i=0; i<arr[1].length; i++) {
if (arr[0].toLowerCase().indexOf(checkArr[i]) == -1) {
return false;
}
}
return true;
}
@jamesattard
jamesattard / sumPrimes.js
Created February 5, 2017 23:24
Sum all the prime numbers up to and including the provided number
function sumPrimes(num) {
// Sum all the prime numbers up to and including the provided number.
//
// A prime number is defined as a number greater than one and having only
// two divisors, one and itself. For example, 2 is a prime number because
// it's only divisible by one and two.
//
// The provided number may not be a prime.
# Backup database Globals
su - postgres -c "pg_dumpall -g --file=/tmp/globals.sql;"
# Backup all databases
su - postgres -c 'psql -At -c "SELECT datname FROM pg_database WHERE NOT datistemplate"' | \
while read f;
do su - postgres -c "pg_dump --format=c --file=/tmp/$f.sqlc $f";
done;
# First get ID of running container
$ docker ps
CONTAINER ID ...
5776d1849024 ...
# Next we take a snapshot of the docker container by first pausing (-p) the container
$ docker commit -p 5776d1849024 mysql
e09f9ac65c8b3...
# The commit arg saves the entire snapshot as a docker image with a name mysql: