Skip to content

Instantly share code, notes, and snippets.

View 4lun's full-sized avatar

Alun Davey 4lun

View GitHub Profile
@4lun
4lun / .bashrc
Last active March 21, 2016 19:20
root .profile - Scary red text so that you know when you're logged in as root
export PS1="\[\e[1;41m\]\u\[\e[0m\]\[\e[0;41m\]@\h\[\e[0;41m\]\w \[\e[1;37m\]\$ \[\e[0m\] "
@4lun
4lun / markdown.css
Created September 6, 2014 17:06
Style that makes standard HTML look like Markdown
body {
margin: 0;
padding: 50px 100px;
font-family: monospace;
font-size: 16px;
color: #888;
background: #f1f1f1;
line-height: 1.5;
font-weight: 400;
}
@4lun
4lun / colorrun.cheat.js
Last active August 29, 2015 14:08
Cheat for http://colorrun.pl/ (run in the console after starting) :P
function hackThePlanet() {
var colors = document.querySelectorAll('.color'),
values = [];
for(var i = 0; i < colors.length; i++) {
var rgb = colors[i].style.backgroundColor;
values[i] = 0;
rgb.replace(/[^\d,]+/g, '')
.split(',')
@4lun
4lun / str.slug.js
Created December 10, 2014 16:13
Slug function in JS matching the Laravel 4 implementation (Str::slug) - Note: does not include the transliteration of a UTF-8 value to ASCII
function slug(title, separator) {
if(typeof separator == 'undefined') separator = '-';
// Convert all dashes/underscores into separator
var flip = separator == '-' ? '_' : '-';
title = title.replace(flip, separator);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
title = title.toLowerCase()
.replace(new RegExp('[^a-z0-9' + separator + '\\s]', 'g'), '');
@4lun
4lun / trello.checklistCount.js
Created January 27, 2015 13:52
Counts the amount of checklist items on a Trello board to and how many are complete (run in the console).
var total=0,complete=0;$('.badge-text').filter(function(i,e) { return ((e.innerHTML).indexOf('/')!== -1); }).each(function(i,e){ var s = (e.innerHTML).split('/');total+=+(s[1]);complete+=+(s[0]) }); console.log('Checklist items complete: '+complete+'/'+total,'('+Math.round((complete/total)*100)+'%)');

Keybase proof

I hereby claim:

  • I am 4lun on github.
  • I am 4lun (https://keybase.io/4lun) on keybase.
  • I have a public key whose fingerprint is C949 318D 7807 1205 6E75 ACED 66E8 91AA 52E1 299B

To claim this, I am signing this object:

# USAGE:
# ./svn-to-git.sh http://$svnrepo/ http://$gitrepo/
#
# Credit: http://blog.jessitron.com/2013/08/converting-from-svn-to-git.html
REPO="$1"
echo -e "\nDownloading svn repository and converting to local git repository: '$(basename $REPO)'\nURL: $REPO\n"
git svn clone --stdlayout --prefix=svn/ "$REPO" ${REPO##*/}
cd "$(basename $REPO)"
@4lun
4lun / git-branch-rolllback.sh
Last active August 29, 2015 14:18
Roll back history of git branch to specific commit and push to remote
# Will wipe out the history following this commit
git reset --hard <commit-hash>
git push -u origin master -f
cd /home/git/gitlab; \
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \
sudo service gitlab stop; \
if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb -y; else sudo -u git -H ruby script/upgrade.rb -y; fi; \
cd /home/git/gitlab-shell; \
sudo -u git -H git fetch; \
sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`; \
cd /home/git/gitlab; \
sudo service gitlab start; \
sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
server {
listen 80;
server_name jenkins.domain.tld;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 150;