Skip to content

Instantly share code, notes, and snippets.

View RobbiNespu's full-sized avatar
:octocat:
Wut?

Robbi Nespu RobbiNespu

:octocat:
Wut?
View GitHub Profile
@RobbiNespu
RobbiNespu / query_finder.sql
Created November 28, 2016 17:35 — forked from mezis/query_finder.sql
Finding long-running queries in MySQL
SELECT id,state,command,time,left(replace(info,'\n','<lf>'),120)
FROM information_schema.processlist
WHERE command <> 'Sleep'
AND info NOT LIKE '%PROCESSLIST%'
ORDER BY time DESC LIMIT 50;
<?php
function getService()
{
// Creates and returns the Analytics service object.
// Load the Google API PHP Client Library.
require_once 'google-api-php-client/src/Google/autoload.php';
// Create and configure a new client object.
@RobbiNespu
RobbiNespu / backup-to-git.sh
Created January 3, 2017 06:38 — forked from Amitesh/backup-to-git.sh
DB Backup to Git
#!/bin/bash
##
# MySQL DB dump to Git commit
#
# Dumps the specified mysql database to the given location and commits it and
# the previous database to the Git repository.
#
# It is assumed you have already setup the Git respository to only be the
# a checkout of the database backup location
@RobbiNespu
RobbiNespu / gist:336ec33ff4e4f8bed9c3a8eb0185fb76
Created January 27, 2017 02:10
Email send by mistake (Intercom)
Hi FakhrXuXXXXX,
You may have received an email from us today regarding an Intercom free trial. We made a mistake which caused it to send to the wrong audience.
There's nothing wrong with Intercom; this was human error. Mine, in fact. disappointed I'm really sorry about that.
RuairXXXí
@RobbiNespu
RobbiNespu / gist:83ea3f2e1312141e7348dcaef3be1a6c
Created February 15, 2017 01:33
Fedora Android Studio KVM
Kvm
===
Enable kvm virt acceleration for Android Virtual Device emulator
Open Terminal window and type:
- su -c "dnf install @virtualization"
- su -c "systemctl start libvirtd"
Verify that the kvm kernel modules were properly loaded
- download f.lux for Linux from https://justgetflux.com/linux.html
- extract it on a folder
- digit these commands on a Terminal window:
$mv [YOUR FOLDER]/xflux /home/<user>/.local/bin/
$chmod 755 /home/<user>/.local/bin/xflux
Now you can run flux with xflux command.
But you have to define your zipcode or latitude.
@RobbiNespu
RobbiNespu / gist:4ab058352f76a9879720e9ccffb3a152
Created February 24, 2017 14:40
how to optimize apache to recive huge traffic
I was able to do about 4K concurrent connections with this setup.
Using Centos 6.7 64bit Apache httpd-2.2.15-47.el6.centos.x86_64
a Virtual Machine 4x CPU’s and 4GBs of memory, I have 2 disks, one for /var and other for the rest.
Important to understand, this apache servers only one static image we use for the BI team.
It does recieve and log a huge cookie and sends a 43 byte 1×1.gif image.
Atention: It may not work right for dynamic web servers, as I use the mod_cache.
The impressive thing, it uses almos no CPU and memory is doing fine.
I did my benchmark using ab (apache benchmark) with 2 remote server in the sam LAN.
They key thing is to make a change and test it.
Some kernel tuning for the network
@RobbiNespu
RobbiNespu / gist:7d947760ca4a3789805aa3606c65ddcd
Created February 24, 2017 14:42
Server Optimization/Hardening
Extended Binary Hardening
========================================================
chmod 700 /usr/bin/wget
chmod 700 /usr/bin/lynx
chmod 700 /usr/bin/bcc
chmod 700 /usr/bin/byacc
chmod 700 /usr/bin/cc
chmod 700 /usr/bin/gcc
chmod 700 /usr/bin/i386-redhat-linux-gcc
#!/bin/bash
# Destination: ~/.pomodoro/hooks/work.d/
# Goal: block access to Twitter and Facebook while in a Pomodoro
# Note: won't work if you use Chrome, as it maintains an internal (not flushable from CLI) DNS cache. Fuck it.
# This file must be able to touch "/etc/hosts":
# The best way would be to create a group able to modify the "/etc/hosts" file:
# $ sudo addgroup host-manager
# $ sudo chgrp host-manager /etc/hosts