Skip to content

Instantly share code, notes, and snippets.

View clasense4's full-sized avatar
🎯
Focusing

Fajri Abdillah clasense4

🎯
Focusing
View GitHub Profile
@clasense4
clasense4 / lambda.js
Created July 20, 2017 17:32
Create DynamoDB Table from Lambda function
// Configuring the AWS SDK
var AWS = require('aws-sdk');
AWS.config.update({region: 'REGION'});
exports.handler = (event, context, callback) => {
// TODO implement
// create DynamoDB service object
var dynamodb = new AWS.DynamoDB({region: 'REGION', apiVersion: '2012-08-10'});
/* This example creates a table named Music. */
var params = {
@clasense4
clasense4 / disable-xdebug.sh
Last active November 19, 2016 12:25 — forked from hacfi/disable-xdebug.sh
OS X homebrew php 7.0 enable/disable xdebug extension script
#!/bin/sh
sed -i.default "s/^zend_extension=/;zend_extension=/" /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
echo "xdebug disabled"
@clasense4
clasense4 / app.php
Created November 10, 2016 05:59
AWS EB Worker Laravel Route Separation
<?php
# file : bootstrap/app.php
# ........
/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
@clasense4
clasense4 / command.sh
Created October 22, 2016 03:24
Fixing awk problem in OSX el capitan
brew unlink gawk
brew reinstall awk
awk
@clasense4
clasense4 / scrapy_result
Created March 3, 2016 22:55
Scrapy grab metadata
[root@cls-ebizu ~]# scrapy shell "http://www.focus.de/sport/formel1/michael-schumacher-in-schumachers-abwesenheit-ausstellung-zur-formel-1-karriere-eroeffnet_id_5286608.html"
2016-03-03 17:52:54 [scrapy] INFO: Scrapy 1.0.5 started (bot: scrapybot)
2016-03-03 17:52:54 [scrapy] INFO: Optional features available: ssl, http11, boto
2016-03-03 17:52:54 [scrapy] INFO: Overridden settings: {'LOGSTATS_INTERVAL': 0, 'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter'}
2016-03-03 17:52:55 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, CoreStats, SpiderState
2016-03-03 17:52:55 [boto] DEBUG: Retrieving credentials from metadata server.
2016-03-03 17:52:55 [boto] ERROR: Caught exception reading instance data
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/boto/utils.py", line 210, in retry_url
r = opener.open(req, timeout=timeout)
@clasense4
clasense4 / scrapy
Last active December 29, 2016 04:19
scrapy on centos 7.3, work with digitalocean 512mb ram
# Base package
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
yum update -y
# Add swap
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile swap swap sw 0 0" >> /etc/fstab
@clasense4
clasense4 / scrapy
Created February 24, 2016 01:22
Scrapy Regex Unicode Error, got no solution for this
[root@cls rss_crawler]# scrapy crawl news
http://www.focus.de/sport/formel1/formel-1-idol-in-marburger-ausstellung-alles-dreht-sich-um-michael-schumacher-wie-es-ihm-geht-bleibt-ungewiss_id_5292575.html
2016-02-23 20:15:06 [scrapy] INFO: Scrapy 1.0.5 started (bot: rss_crawler)
2016-02-23 20:15:06 [scrapy] INFO: Optional features available: ssl, http11, boto
2016-02-23 20:15:06 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'rss_crawler.spiders', 'SPIDER_MODULES': ['rss_crawler.spiders'], 'BOT_NAME': 'rss_crawler'}
2016-02-23 20:15:06 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, LogStats, CoreStats, SpiderState
2016-02-23 20:15:06 [boto] DEBUG: Retrieving credentials from metadata server.
2016-02-23 20:15:06 [boto] ERROR: Caught exception reading instance data
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/boto/utils.py", line 210, in retry_url
@clasense4
clasense4 / tsung.md
Created November 17, 2015 08:52
Install tsung centos 7

Install tsung centos 7

yum -y install erlang perl perl-RRD-Simple.noarch perl-Log-Log4perl-RRDs.noarch gnuplot perl-Template-Toolkit
wget http://tsung.erlang-projects.org/dist/tsung-1.6.0.tar.gz
tar xfz tsung-1.6.0.tar.gz
cd tsung-1.6.0
./configure && make && make install

mkdir /root/.tsung
@clasense4
clasense4 / CustomerCest.php
Last active September 26, 2018 06:33
Yii2 + Codeception Cookie & Session problem / error, still got no solution for this. The cookie / session won't be share between tests (function). [Edit] check acceptance.yml
<?php
// use tests\codeception\backend\AcceptanceTester;
use tests\codeception\backend\acceptance\BaseStep;
class CustomerCest
{
public $user = 'Fajri';
// private $cookie = 'xyz';
@clasense4
clasense4 / backup.sh
Created June 16, 2015 23:10
Simple backup file use it with crontab
#!/bin/sh
now="$(date +'%Y_%m_%d_%H_%M')"
filename_app="CRM_APP_$now".tar.gz
filename_db="CRM_DB_$now".sql.gz
backupfolder="/home/backup"
backupfolder_app="/var/www/website"
fullpathbackupfile_db="$backupfolder/$filename_db"
fullpathbackupfile_app="$backupfolder/$filename_app"
# execute mysql
mysqldump -u user -pPasswd -h xxx.xxx.xxx.xxx databases | gzip -9 > "$fullpathbackupfile_db"