Skip to content

Instantly share code, notes, and snippets.

View lym's full-sized avatar
🎾

salym lym

🎾
View GitHub Profile
@lym
lym / gist:9994702
Created April 5, 2014 17:06
Install chrome java plugin on Ubuntu
$ mkdir /opt/google/chrome/plugins; # and cd into it
$ sudo apt-get install icedtea-6-plugin # install icedtea, depending on your open-jdk version, of course.
$ sudo ln -s /usr/lib/jvm/java-6-openjdk/jre/lib/i386/IcedTeaPlugin.so # create symbolic link, depending on your processor architecture
# that's it, start/restart chrome and you're off :-)
@lym
lym / get_db_owner
Created January 15, 2015 16:05
postgresql: retrieve owner of specified database
SELECT d.datname as "Name",
pg_catalog.pg_get_userbyid(d.datdba) as "Owner"
FROM pg_catalog.pg_database d
WHERE d.datname = 'database_name'
ORDER BY 1;
@lym
lym / django_console
Created February 5, 2015 08:01
Start an interactive shell in a django project
# With manage.py
$ env/bin/python manage.py shell
# Without manage.py
$ export DJANGO_SETTINGS_MODULE=[module containing your settings]
$ env/bin/python
>>> import django
>>> django.setup()
@lym
lym / gist:8269619
Last active January 2, 2016 07:19
Fix the Ubuntu GPG BADSIG Error. Adopted from: http://www.ubuntugeek.com/how-to-fix-the-ubuntu-gpg-error-badsig.html
$ sudo -i
# apt-get clean
# cd /var/lib/apt
# mv lists lists.old
# mkdir -p lists/partial
# apt-get clean
@lym
lym / gist:8498336
Last active January 3, 2016 17:49
remove/unistall old or unused kernels from you ubuntu box.
$ uname -r # to get the current functional kernel
$ dpkg --list | grep linux-image # use your imagination.
$ sudo apt-get purge linux-image-x.x.x.x-generic # or whatever the name of the version you want to uninstall is.
def _check_meter_image(self, meter_image): # meter_image is a base64-encoded string
err_msg = 'Please take a photograph of the meter'
if meter_image:
pre_img = base64.encodestring(bytearray(meter_image, 'utf8'))
pre_img2 = base64.decodestring(pre_img)
img_file = io.BytesIO(pre_img2)
img = Image.open(img_file)
print(img.filename)
if img.format == 'JPEG':
return True
@lym
lym / rubocop_pre_commit_hook
Created April 16, 2018 11:40 — forked from mpeteuil/rubocop_pre_commit_hook
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified.
#!/usr/bin/env ruby
require 'english'
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/.freeze
changed_files = `git status --porcelain`.split(/\n/).
select { |file_name_with_status|
file_name_with_status =~ ADDED_OR_MODIFIED
@lym
lym / capybara cheat sheet
Created April 18, 2018 11:41 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@lym
lym / macos-recovery-server.md
Created November 3, 2018 13:14
Fixing "The recovery server could not be contacted" in MacOS High Sierra

I was trying to reinstall High Sierra on an older MacBook Air using internet recovery and I kept on getting an error message when trying to reinstall High Sierra.

The recovery server could not be contacted

It appears that this has to do with the time on the machine not being synchronized, so when the MacBook tries to reach out to the recovery server the certificates do not validate and we get this useless error message.

To fix this.

  1. Open up a Terminal from the utilities menu
  2. Enter the following command
@lym
lym / gist:89a1dd28a8ca27e87c68d3325e7b0be6
Created November 28, 2018 13:52
[Fix] Headless::Exception: Display socket is taken but lock file is missing - check the Headless troubleshooting guide
mkdir /tmp/.X11-unix && sudo chmod 1777 /tmp/.X11-unix && sudo chown root /tmp/.X11-unix/