Skip to content

Instantly share code, notes, and snippets.

View alkavan's full-sized avatar
😀
sup?

Igal Alkon alkavan

😀
sup?
View GitHub Profile
@alkavan
alkavan / mime-type-extract-rfc2045.js
Created March 29, 2017 20:26
MIME Type extraction and validation by RFC 2045, RFC 833
// Pattern (RFC 833, RFC 2045, https://www.ietf.org/rfc/rfc2045.txt)
// Tested against 1200~ types @ http://www.iana.org/assignments/media-types/media-types.xhtml
const pattern = /^(text|image|audio|video|application+)\/([a-zA-Z\d\+\-\.\:\_]+)$/;
// Tests
pattern.test("application/x-bzip2");
pattern.test("application/vnd.amazon34.ebook");
pattern.test("application/octet-stream");
// Match
@alkavan
alkavan / CentOS_7.x_(PHP_7.3_Postgres_10.x).md
Last active September 10, 2021 00:54
CentOS 7.x - Web Server Bootstrap (DigitalOcean/Bluemix)

CentOS 7.x - Web Server Bootstrap

General (and init)

Update system

yum update

Set your timezone

@alkavan
alkavan / requirejs-amd-definition-template.js
Last active August 29, 2015 14:01
Require.js (AMD) Definition Template
/**
* An example how to define library for require.js (AMD)
* Copyright (C) 2014 Igal Alkon
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@alkavan
alkavan / howto-php-pthreads-arch64.md
Last active July 29, 2017 07:01
How to install the PHP pthreads extension on Arch Linux x86_64

I wanted to test the new stable pthreads extension for PHP on my Arch Linux 64-bit. to install the pthreads extension using pecl you are required to use a compiled version of PHP with the the thread safety support flag --enable-maintainer-zts. the most clean way on Arch would be then rebuild the original package with the flag. this was very important to me to keep my PHP as stable as possible. so here's what you should do ...

First checked what packages dependent on the 'php' package:

pacman -Qii php

#!bash.exe
export SSH_AUTH_SOCK=/tmp/.ssh-socket
echo ;
echo Starting connection with ssh-agent...
ssh-add -l 2>&1 >/dev/null
if [ $? = 2 ]; then
rm -f /tmp/.ssh-script /tmp/.ssh-agent-pid /tmp/.ssh-socket
# Exit status 2 means couldn't connect to ssh-agent; start one now
echo Creating new ssh-agent...
ssh-agent -a $SSH_AUTH_SOCK > /tmp/.ssh-script
# Add new user to sasl database
saslpasswd2 -c -u domain.net webmaster
@alkavan
alkavan / import_db.sh
Last active December 21, 2015 06:19
Script to import MySQL databases from dumps
#/bin/bash
# Export databases first with the following command:
# mysqldump -u user -p db-name > db-name.dbd
# Configure your new database
file_ext=".dbd"
db_user="root"
db_pass="myrootpassword"
#!/bin/bash
sudo yum install gcc make php-devel geoip geoip-devel
sudo pecl install geoip
ls /usr/lib64/php/modules/geoip.so
echo -e "; Enable geoip extension module\nextension=geoip.so\n" >> /etc/php.d/geoip.ini
echo -e "Done installing GeoIP PHP extention!\n"
@alkavan
alkavan / git_commands.md
Last active December 17, 2015 05:39
List of useful GIT commands.

Clean staging area

Remove all deleted files from staging area

git diff --diff-filter=D --name-only -z | xargs -0 git rm

SVN import/export

Read svn author

# Generic Makefile for compiling an executable, with pkg-config dependencies.
CC := clang
PKGS := gtk+-3.0
SRCDIR := src
BUILDDIR := build
CFLAGS := -g -Wall `pkg-config --cflags $(PKGS)`
LIBS := `pkg-config --libs $(PKGS)`
TARGET := app