Skip to content

Instantly share code, notes, and snippets.

View 4lun's full-sized avatar

Alun Davey 4lun

View GitHub Profile
@4lun
4lun / _icons.scss
Last active August 29, 2015 13:56
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
@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 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 / 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;
@4lun
4lun / output
Last active August 29, 2015 14:21
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
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