Skip to content

Instantly share code, notes, and snippets.

@masbog
masbog / http_stream_basic_auth.m
Last active December 23, 2015 13:09
AuthBasic For HTTP streaming .m3u8 with passworded iPCam iOS
NSURLCredential *credential = [[[NSURLCredential alloc]
initWithUser:@"masbog"
password:@"gobmas"
persistence: NSURLCredentialPersistenceForSession] autorelease];
NSURLProtectionSpace *protectionSpace = [[[NSURLProtectionSpace alloc]
initWithHost: @"180.61.3.1"
port:31608
protocol: @"http"
realm: nil
@masbog
masbog / java8oracle.sh
Last active August 29, 2015 13:56
Change OpenJDK to OracleJDK 8 (CentOS 6)
yum -y remove java-1.6.0-openjdk
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.rpm" \
-O /opt/jdk-8-linux-x64.rpm
rpm -Uvh /opt/jdk-8-linux-x64.rpm
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0/jre/bin/java 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0/bin/jar 20000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0/bin/javac 20000
@masbog
masbog / UIImage+ccolor.m
Last active August 29, 2015 14:00 — forked from kevinmcmahon/gist:2295471
Create UIImage from golor
- (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@masbog
masbog / nginx-http_secure_link_module.sh
Last active March 14, 2016 04:38
nginx-http_secure_link_module.sh
@masbog
masbog / libgs_install.sh
Created June 17, 2014 07:50
Installing ghostscript 9 CentOS 6.5 with shared Library
curl -O http://downloads.ghostscript.com/public/ghostscript-9.14.tar.gz &&
tar -xzf ghostscript-9.14.tar.gz &&
cd ghostscript-9.14 &&
./configure &&
make install &&
make so &&
cp ghostscript-9.14/sobin/libgs.so.9.14 /usr/lib &&
ln -s /usr/lib/libgs.so.9.14 /usr/lib/libgs.so &&
mkdir -p /etc/ld.so.conf.d/ &&
echo "/usr/lib/libgs.so" > /etc/ld.so.conf.d/libgs.conf &&
@masbog
masbog / autorreconnect-pptp.sh
Created August 6, 2014 16:45
autoreconnect-pptp
#!/bin/bash
#!/bin/sh
if ping -qnw1 -c1 your_ip_server_from_ppp0 2>&1 >/dev/null
then
echo "Link is up"
else
echo "Link is down, trying to reconnecting..."
pppd call pptp_config_name
fi
@masbog
masbog / ffmpeg_intall.sh
Last active May 30, 2018 00:16
Automation FFmpeg installation script ( https://trac.ffmpeg.org/wiki/CompilationGuide/Centos ) with all plugin and tested in Centos 7
#!/bin/bash
#!/bin/sh
rpm -Uvh http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm &&
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel freetype-devel speex-devel -y &&
mkdir ~/ffmpeg_sources &&
cd ~/ffmpeg_sources &&
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz &&
tar xzvf yasm-1.3.0.tar.gz &&
cd yasm-1.3.0 &&
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" &&
@masbog
masbog / ffmpeg_command
Last active August 29, 2015 14:06
create video with image and lenght using ffmpeg linux terminal
ffmpeg -s 720x576 -r 25 -loop 1 -y -i /root/anon.jpg -t 02:00:00 -acodec libfaac -ac 2 -ar 44100 -ab 128k -async 1 -vcodec libx264 -level 1.3 anon.mp4
if you want to add audio, add -i (audio file location)
#include <bitset>
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
@masbog
masbog / mamp.md
Last active August 29, 2015 14:07 — forked from jfloff/mamp.md

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

@masbog
masbog / bucard.sh
Created October 21, 2014 03:02
bucardo how to initialize 2 postgresql database server
#!/bin/bash
# slave ip server is 10.10.10.10
bucardo install --piddir=/tmp
bucardo add database db_master dbname=database_test
bucardo del database db_master
bucardo add database db_master dbname=database_test addalltables addallsequences
bucardo add database db_slave dbname=database_test host=10.10.10.10 addalltables addallsequences
bucardo add all table --herd=db_master_to_db_slave db=db_master
bucardo add all sequence --herd=db_master_to_db_slave db=db_master
bucardo add all table --herd=db_slave_to_db_master db=db_slave