Skip to content

Instantly share code, notes, and snippets.

@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes
@molotovbliss
molotovbliss / gist:2562551
Last active September 7, 2022 20:18 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 26, 2024 23:26 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@panuta
panuta / gist:3075882
Last active May 7, 2024 13:33
How to setup Django server with virtualenv on Ubuntu Server 12.04

Fix locale problem

Open file /etc/default/locale to add or change LC_ALL to the following

LC_ALL="en_US.UTF-8"

Then logout and login again.

Install necessary packages

@dominicsayers
dominicsayers / elasticsearch.md
Last active March 2, 2024 15:52
Configuring ElasticSearch to use less memory

What I actually did

/etc/security/limits.conf

elasticsearch hard memlock 100000

/etc/default/elasticsearch

@madaboutcode
madaboutcode / commandline-fu.md
Last active November 23, 2020 06:44
Command Line Magic™

Command Line Magic

  • sort -u -t, -k1,1 file - Unique in column
    • u for unique
    • t, so comma is the delimiter
    • k1,1 for the key field 1
  • sed '/^$/d' myFile - remove blank lines from a file
  • find ~/ -type d -maxdepth 3 -exec du -hs '{}' \; - display usage for all folders in a directory
  • curl http://requestb.in/10wkj9v1 -x http://183.220.199.76:8123 - proxy testing
  • curl -o /dev/null -s -w "Connect: %{time_connect} \nTime to first byte: %{time_starttransfer}\nTotal time: %{time_total} \n" <url> - Webpage perf stats using curl
  • Portscan using netcat - nc -z -v 192.168.15.196 1-1000
@alder
alder / gist:1420a45c19cb947e03ce
Created January 12, 2015 16:04
Manually read CSV data in JMeter witn BeanShell
import java.text.*;
import java.io.*;
import java.util.*;
String filename = "oprosnik_" + vars.get("fileNum") + ".csv";
ArrayList strList = new ArrayList();
try {
File file = new File(filename);
@a1ip
a1ip / README.md
Last active April 14, 2020 11:04
Some useful tips for CodeCombat players https://git.io/cocotips
@aserhat
aserhat / 0 - setup
Last active March 23, 2024 14:51
QEMU and HVF
# Summary
A few notes I took to see if I could use MacOS as Hypevirsor in a similar fashion to Linux
I wanted to see how few addons were needed instead of using Parallels, Virtual Box, VM Fsion etc.
The idea is to use QEMU, Hypervisor Framework (https://developer.apple.com/documentation/hypervisor) and some custom host networking.
# Installations
brew install qemu (For controlling Hypervisor Framework)
brew install cdrtools (For making cloud init iso's)
http://tuntaposx.sourceforge.net/download.xhtml (For customer tap based networking)
@r0mdau
r0mdau / find-k8snode-interface.sh
Last active May 3, 2024 13:21
How to get tcpdump for containers inside Kubernetes pods
# find the kube node of the running pod, appear next to hostIP, and note containerID hash
kubectl get pod mypod -o json
# -> save hostIP
# -> save containerID
# connect to the node and find the pods unique network interface index inside it's container
docker exec containerID /bin/bash -c 'cat /sys/class/net/eth0/iflink'
# -> returns index
# locate the interface of the node