Skip to content

Instantly share code, notes, and snippets.

View dhargitai's full-sized avatar
💭
Everything is awesome 😎

David Hargitai dhargitai

💭
Everything is awesome 😎
View GitHub Profile
@dhargitai
dhargitai / gist:6122358
Last active December 20, 2015 11:19
CSS: Image replacement
.ir {
background-color: transparent;
border: 0;
color: transparent;
font: 0/0 a;
text-shadow: none;
}
@dhargitai
dhargitai / gist:6179363
Created August 7, 2013 22:18
php: soft_cut_string
function soft_cut_string($string, $length, $cut_string = '…')
{
$new_string = $string;
if( mb_strlen($new_string) > $length )
{
$last_space_position = mb_strpos($new_string, " ", $length);
$new_string = mb_substr($new_string, 0, $last_space_position) . $cut_string;
}
return $new_string;
@dhargitai
dhargitai / gist:8437796
Created January 15, 2014 14:59
Update statements for Ideal Shop local database after importing UAT database dump
update core_config_data set value='http://ideal.development.local/' where config_id=24;
update core_config_data set value='https://ideal.development.local/' where config_id=26;
update core_config_data set value='https://ideal.lovepets.development.local/' where config_id=183;
update core_config_data set value='http://ideal.lovepets.development.local/' where config_id=183;
update core_config_data set value='https://ideal.lovepets.development.local/' where config_id=184;
@dhargitai
dhargitai / Fancy aliases
Last active August 29, 2015 13:58
Tools for smart (and lazy) people
alias stopallvms='VBoxManage list runningvms | cut -d " " -f 1 | xargs -J % VBoxManage controlvm % savestate'
alias findinphp='find . -type f -name "*.php" | xargs grep -n'
alias what-did-i-work-on-recently='git log --abbrev-commit --date=short -100 --pretty=format:'%ae %ad %Cred%h%Creset -%C(yellow)%d%Creset %C(bold blue)%s%Creset' | grep "<YOUR-GITHUB-EMAIL>" | grep -oE "\d{4}.*"'
alias vless='vim -u /usr/share/vim/vim73/macros/less.vim'
@dhargitai
dhargitai / Forwarding with proxylocal
Created April 14, 2014 18:20
Describe how you can forwarding with Proxylocal to view sites in Vagrant virtual machine
$ gem install proxylocal
# Into Vagrantfile:
# config.vm.network "forwarded_port", guest: 80, host: 8080
$ vagrant reload
# In new terminal window:
$ proxylocal 8080
# You can copy the forwarded URL from the output. The forwarding lives until you terminate the process.
# Convert m4a to mp3
ffmpeg -i audioFile.m4a -codec:v copy -codec:a libmp3lame -q:a 2 audioFile.m4a.mp3
# Download extracted audio content from youtube video
youtube-dl -x "Youtube-link"
# Find and replace "Oldcontent" to "Newcontent" in FILENAME
sed -i.bak s%Oldcontent%Newcontent%g FILENAME
# Replace a word with another in all file under a directory structure
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
@dhargitai
dhargitai / capistrano-config-for-ssh-pem-file
Created May 2, 2014 08:02
Config Capistrano to use a PEM file for SSH authentication
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
ssh_options[:auth_methods] = ["publickey"]
ssh_options[:keys] = ["~/.ssh/key.pem"]
$("input").keypress(function(event) {
if (event.which == 13) {
event.preventDefault();
$(this).closest("form").submit();
}
});
@dhargitai
dhargitai / jQuery definition
Created May 26, 2014 05:27
Define jQuery the right way
(function($) {
$(document).ready(function() {
});
})(jQuery);