Skip to content

Instantly share code, notes, and snippets.

View mfurlend's full-sized avatar

Mikhail Furlender mfurlend

  • WeatherBELL Analytics
  • New York, NY
View GitHub Profile
sudo usermod -a -G www-data <some_user>
Then set the correct permissions on /var/www.
sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www
Additionally, you should make the directory and all directories below it "set GID", so that all new files and directories created under /var/www are owned by the www-data group.
sudo find /var/www -type d -exec chmod 2775 {} \;
Find all files in /var/www and add read and write permission for owner and group:
@mfurlend
mfurlend / key:value => value:key
Created June 6, 2014 14:32
regex for javascript to switch key:value => value:key for objects
search: ([ ]*)(.*?):\s?([^,\n\r]*)
repalce: $1$3:$2
example:
var regionNames = {
"australia":"Australia",
"brazil":"Brazil",
"canada":"Canada",
"caribbean":"Caribbean",
"centamer":"Central America",
@mfurlend
mfurlend / gist:2f3884dd24aa0efcbcb4
Last active August 29, 2015 14:03
Install Python 2.7.6 alongside default on Centos 6.5 x86_64 with conflicting 32 bit libz library in default path, then setup virtualenv and configure a directory
#BUILD AND INSTALL PYTHON
su
yum groupinstall -y development
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel tk-devel gdbm-devel ncurses-devel readline-develxz-libs
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz --no-check-certificate
xz -d Python-2.7.6.tar.xz
tar -xvf Python-2.7.6.tar
cd Python-2.7.6
mkdir ~/libzbackup
mv /usr/local/lib/libz* ~/libzbackup

chgrp dev /path/to/dir

chmod -R g+rwxs /path/to/dir

s = SGID

@mfurlend
mfurlend / gist:72de8e155d805ab65c0d
Created October 4, 2014 22:58
ssh tunnel for mysql
ssh -fNg -L 3307:127.0.0.1:3306 user@target_server
@mfurlend
mfurlend / datatunnel.zsh
Last active December 7, 2015 16:42
SSH tunnel to remote MySQL server. From localhost:3307 to root@dataserver:3306. Chkconfig compatible. (chkconfig --add datatunnel). Place script in /etc/init.d/dataserver
#! /bin/zsh
#
# Init file for dataserver SSH tunnel to dataserver's MySQL server
#
# chkconfig: 2345 95 5
# description: SSH tunnel to dataserver's MySQL server. Runs locally at port 3307.
#
# processname: data_tunnel
DATSRV=("${(@f)$(getent hosts dataserver 10.0.0.188 | uniq | awk '{print $1"\n"$2}')}")
@mfurlend
mfurlend / heartbeat
Created November 11, 2014 17:33
heartbeat css3
@-webkit-keyframes heartbeat {
0% { -webkit-transform: scale(1); }
50% { -webkit-transform: scale(0.9); }
100% { -webkit-transform: scale(1); }
}
/* line 88, ../sass/login_header.scss */
#el:hover{
-webkit-animation-name: heartbeat;
-webkit-animation-duration: 200ms;
-webkit-transform-origin:50% 50%;
@mfurlend
mfurlend / gist:e12548d714738daa5b03
Created December 15, 2014 18:52
install PIL on centos
pip install PIL --allow-unverified PIL --allow-all-external
@mfurlend
mfurlend / gist:f5a001e650ac5b8388fd
Created February 10, 2015 20:22
Official RFC email validation regex
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
@mfurlend
mfurlend / xsl.xsl
Last active August 29, 2015 14:16
XSLT for parsing dwml from forecast.weather.gov
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>