Skip to content

Instantly share code, notes, and snippets.

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

Rahmat Ramadhan rririanto

🏠
Working from home
View GitHub Profile
@rririanto
rririanto / gist:34d6109bd3c413c3dc53
Created January 25, 2016 02:48
indonesian-stopwords.txt
about
acara
ada
adalah
adanya
adapun
aeur
after
agak
agaknya
@rririanto
rririanto / server.py
Last active April 20, 2016 00:54
Python SimpleHTTPRequestHandler set Access-Control-Allow-Origin header
'''
@jimmyromanticde
Note:
python 2.x Only
Problem:
Error browser log
XMLHttpRequest cannot load http://127.0.0.1:8000/visitor.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
'''
@rririanto
rririanto / search.py
Created March 25, 2016 10:26
Python Small Script to find text string in files
#!/usr/bin/env python
'''
@jimmyromanticde
Problem
Find or Search text string in files
'''
DIRFOLDER = '/home/romanticdevil/myworkspace/Dj1.4/project/newversion1.0/titik_tanya'
import os, re
text = raw_input('string search: ')
@rririanto
rririanto / random_generator.php
Last active March 27, 2016 12:39
PHP generate Random String
<?php
function create_costumer_key($length=8,$use_upper=1,$use_lower=1,$use_number=1,$use_custom=""){
$upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$lower = "abcdefghijklmnopqrstuvwxyz";
$number = "0123456789";
if($use_upper){
$seed_length += 26;
$seed .= $upper;
}
if($use_lower){
@rririanto
rririanto / generator_urut.php
Created April 3, 2016 20:00
Generator No Urut
<?php
function generateUrut($id)
{
$tz_object = new DateTimeZone('Asia/Makassar');
//date_default_timezone_set('Brazil/East');
$datetime = new DateTime();
$datetime->setTimezone($tz_object);
$dater = $datetime->format('Ymd');
@rririanto
rririanto / models.py
Last active March 28, 2022 16:09
Django Delete File when remove an Object & Delete Old File when updating an Object
'''
@jimmyromanticde
Note:
python 2.x Only
Django >= 1.4
Problem:
1. django cannot remove files when deleting an objects in models/database
2. django cannot update/replace/delete files when updating an objects in models/database
@rririanto
rririanto / solved_server_1.txt
Last active April 19, 2016 06:28
[SOLVED] Django AWS ec2 Unhandled Exception An unhandled exception was thrown by the application.
"
Problem:
Server Nginx
Django
Unhandled Exception An unhandled exception was thrown by the application.
"
The Story when i try to deploy a new code in new staging server on aws ec2.
i was intalling anything before. library, dependency and etc
@rririanto
rririanto / pypdf_to_image.py
Last active June 16, 2020 06:23
Python Convert PDF to Image
"""
Problem:
How to Convert PDF to Image with Python Script ?
Installation:
I use ubuntu OS 14.04
We use wrapper for ImageMagick [http://www.imagemagick.org/script/index.php] to Convert The PDF file
in Python do:
$ sudo apt-get install libmagickwand-dev
@rririanto
rririanto / views.py
Last active April 29, 2016 02:36
Penjelasan Singkat tentang POST & GET Django
Penjelasan Singkat tentang POST & GET Django
POST GET
Nilai variabel tidak ditampilkan di URL | Nilai variabel ditampilkan di URL sehingga user dapat dengan mudah memasukkan nilai
| variabel baru
Lebih aman | Kurang aman
Tidak dibatasi panjang string | Dibatasi panjang string sampai 2047 karakter
Pengambilan variabel dengan request.POST.get | Pengambilan variabel dengan request.POST.get
Biasanya untuk input data melalui form | Biasanya untuk input data melalui link
@rririanto
rririanto / noparse.py
Created May 16, 2016 08:14
Django 1.8 template block tag {% noparse %} renders template syntax characters within the block as normal text.
"""
Original Version from
dgouldin https://gist.github.com/dgouldin/634534
Modify by jimmyromanticde
Problem:
'module' object has no attribute 'module' object has no attribute 'TOKEN_TEXT'
"""