Skip to content

Instantly share code, notes, and snippets.

View antoniputra's full-sized avatar
🏠
Working from home

Antoni Putra antoniputra

🏠
Working from home
View GitHub Profile
@arryanggaputra
arryanggaputra / FirstImage.php
Last active September 3, 2015 09:34
Get first image, if there's no image give the default Image URL
<?php
preg_match_all('~<img ([^>]+)>~i', $yourLongArticle, $matches);
$images = [];
foreach ($matches[1] as $str) {
preg_match_all('~([a-z]([a-z0-9]*)?)=("|\')(.*?)("|\')~is', $str, $pairs);
$images[] = array_combine($pairs[1], $pairs[4]);
}
if (!empty($images[0])) {
return $images[0]['src'];
}
@alexbilbie
alexbilbie / jenkins.md
Created August 13, 2013 14:36 — forked from skl/jenkins.md

Creating a new Jenkins Server

First step, make sure java -version reports 1.6 or higher. If the command fails or the version isn't high enough, download the latest version of Java JDK from Oracle (http://www.oracle.com/technetwork/java/javase/downloads/index.html) (jdk-7u25-linux-x64.tar.gz at the time of writing) - a quick uname -m will let you know if you need the 32 or 64bit version. Installation instructions are available here (http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html#install-64).

My preference is to extract these to /usr/local and then ln -s /usr/local/jdk1.7.0_25 /usr/local/jdk.

Add /usr/local/jdk/bin to your $PATH.

Download the latest Jenkins WAR (1.519 currently) file from http://mirrors.jenkins-ci.org/war/latest/.

@fideloper
fideloper / install.sh
Created October 28, 2013 12:41
Vagrant Provisioning Script for Python 2.7 applications
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
echo ">>> Installing Base Items"
# Install base items
@antoniputra
antoniputra / README.md
Created February 11, 2016 16:23 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@fideloper
fideloper / ngxhost.sh
Created February 18, 2014 02:14
Vhost creation file for nginx
#!/usr/bin/env bash
if [ $EUID -ne 0 ]; then
echo "You must be root: \"sudo ngxvhost\""
exit 1
fi
# May need to run this as sudo!
# I have it in /usr/local/bin and run command 'ngxvhost' from anywhere, using sudo.
@achmadfatoni
achmadfatoni / ssl_nginx.conf
Last active December 26, 2017 21:15
letsencrypt laravel configuration
## http://domain.com and http://www.domain.com redirect to https://www.domain.com
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name domain.com www.domain.com;
include /etc/nginx/snippets/letsencrypt.conf;
location / {
return 301 https://www.domain.com$request_uri;
<VirtualHost *:80>
ServerName 192.168.33.10.xip.io
DocumentRoot /vagrant
<Directory /vagrant>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<?php
require __DIR__ . '/vendor/autoload.php';
$dsn = 'mysql:dbname=db1;host=127.0.0.1';
$user = 'root';
$password = '(disensor)';
try {
$dbh = new PDO($dsn, $user, $password);
@sergeylukin
sergeylukin / optimg.sh
Last active July 3, 2019 07:15
Shell script for JPGs and PNGs optimization
#!/usr/bin/env sh
#
# This script automates images optimization
# is mainly used by a developer who manually
# can execute it when adding new images to the
# project
#
# Download and compile following binaries:
#
# - [jpegtran](http://www.ijg.org/)