Skip to content

Instantly share code, notes, and snippets.

Avatar

Alun Davey 4lun

View GitHub Profile
@4lun
4lun / _icons.scss
Last active Aug 29, 2015
Auto generate icon sprite and classes from icon/ directory. Resulting icons will be have .i-<filename> classes. Needs to be placed on an i element or on an element that includes the .i class
View _icons.scss
@import "compass/utilities/sprites";
$icon: sprite-map("icon/*.png", $layout: smart);
i, .i {
display: inline-block;
vertical-align: middle;
background-repeat: no-repeat;
background-position: top left;
background-image: $icon;
@4lun
4lun / markdown.css
Created Sep 6, 2014
Style that makes standard HTML look like Markdown
View markdown.css
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 Aug 29, 2015
Cheat for http://colorrun.pl/ (run in the console after starting) :P
View colorrun.cheat.js
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 / trello.checklistCount.js
Created Jan 27, 2015
Counts the amount of checklist items on a Trello board to and how many are complete (run in the console).
View trello.checklistCount.js
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)+'%)');
View keybase.md

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:

View svn-to-git.sh
# 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 Aug 29, 2015
Roll back history of git branch to specific commit and push to remote
View git-branch-rolllback.sh
# Will wipe out the history following this commit
git reset --hard <commit-hash>
git push -u origin master -f
View gitlab-update.sh
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
View jenkins
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;
@4lun
4lun / output
Last active Aug 29, 2015
Generates solutions for the maths puzzle for Vietnamese eight-year-olds. UPDATE: Missing quite a few answer combinations, see comment thread here: http://www.theguardian.com/science/alexs-adventures-in-numberland/2015/may/20/can-you-do-the-maths-puzzle-for-vietnamese-eight-year-olds-that-has-stumped-parents-and-teachers#comment-52484375
View output
8, 9, 6, 1, 3, 4, 7, 5, 2
8, 9, 3, 6, 5, 1, 2, 7, 4
7, 9, 3, 1, 2, 5, 6, 8, 4
9, 8, 2, 4, 5, 7, 6, 1, 3
7, 6, 1, 9, 5, 4, 2, 8, 3
9, 8, 6, 4, 5, 1, 7, 2, 3
7, 6, 1, 4, 3, 8, 9, 5, 2
5, 7, 1, 3, 4, 9, 8, 2, 6
7, 6, 4, 1, 3, 8, 5, 9, 2
8, 9, 6, 3, 5, 1, 2, 7, 4
You can’t perform that action at this time.