Skip to content

Instantly share code, notes, and snippets.

View mystix's full-sized avatar

Marc mystix

  • Singapore
View GitHub Profile
@mystix
mystix / .bashrc
Created May 9, 2013 11:48
[LINUX] Setup ssh-agent for SSH logins
# setup ssh-agent (see http://mah.everybody.org/docs/ssh)
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
@mystix
mystix / install-elasticsearch-debian
Last active March 19, 2023 15:14 — forked from karussell/install-elasticsearch-debian
Install ElasticSearch on Debian
VERSION=0.20.6
sudo apt-get update
sudo apt-get install openjdk-6-jdk
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.deb
sudo dpkg -i elasticsearch-$VERSION.deb
# be sure you add "action.disable_delete_all_indices" : true to the config!!
Ext.define('Ext.ux.AudioPlayer', {
extend : 'Ext.Container',
xtype : 'audioplayer',
config : {
url : null,
height : 40,
layout : {
@mystix
mystix / magento-reset-dashboard.sql
Last active May 3, 2022 22:16
Magento: reset dashboard data
SET foreign_key_checks = 0;
-- Last 5 Search Terms / Top 5 Search Terms
TRUNCATE TABLE catalogsearch_fulltext;
TRUNCATE TABLE catalogsearch_query;
TRUNCATE TABLE catalogsearch_result;
-- Dashboard stats (e.g. "Most Viewed Products" etc)
TRUNCATE TABLE report_compared_product_index;
TRUNCATE TABLE report_event;
@mystix
mystix / mage-update-associated-price.php
Last active April 17, 2018 11:59
magento - grab all simple products having prices different from their parent configurable product, then update them to match
<?php
$store_id = 0;
$action = "view";
// bootstrap magento (default store)
require_once('app/Mage.php'); // path to magento
umask(0);
Mage::app()->setCurrentStore($store_id); // TODO - 3
@mystix
mystix / clean-mysql-dump.sh
Created January 2, 2013 11:21
Remove DEFINER statements from MySQL db dump
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <mysql db dump>"
exit 1
elif [[ ! -f $1 ]]; then
echo "File not found: $1"
exit 1
fi
@mystix
mystix / ActiveRepository.rb
Created December 5, 2012 08:23 — forked from bokmann/ActiveRepository.rb
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@mystix
mystix / pagination.md
Created November 22, 2012 06:48 — forked from awesome/pagination.md
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@mystix
mystix / hash_deep_diff.rb
Created November 22, 2012 06:36 — forked from awesome/hash_deep_diff.rb
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@mystix
mystix / install-rbenv-user.sh
Created October 13, 2012 15:53 — forked from antage/install-rbenv-user.sh
rbenv system-wide installation on Debian Squeeze
#!/bin/bash
aptitude update
aptitude -y install build-essential git-core zlib1g-dev libssl-dev libreadline6-dev
# rubygems: skip ri and rdoc on production server
echo '---