# rupiah.py
# ---------------
import locale
def rupiah_format(angka, with_prefix=False, desimal=2):
locale.setlocale(locale.LC_NUMERIC, 'IND')
rupiah = locale.format("%.*f", (desimal, angka), True)
if with_prefix:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==== CENTOS 7 LEMP STACK INSTALLATION ==== | |
0. Make sure the centos 7 server have internet connection | |
1. Install the EPEL Repository | |
sudo yum -y install epel-release | |
2. Install the Remi Repository | |
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm | |
3. Install Nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This can be found in the Symfony\Component\HttpFoundation\Response class | |
const HTTP_CONTINUE = 100; | |
const HTTP_SWITCHING_PROTOCOLS = 101; | |
const HTTP_PROCESSING = 102; // RFC2518 | |
const HTTP_OK = 200; | |
const HTTP_CREATED = 201; | |
const HTTP_ACCEPTED = 202; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scrapy.spider import Spider | |
from scrapy.contrib.spiders import CrawlSpider, Rule | |
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor | |
from scrapy.selector import Selector | |
from scrapy.item import Item, Field | |
import urllib | |
class Question(Item): | |
tags = Field() | |
answers = Field() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/config.py | |
# -*- coding: utf-8 -*- | |
import os | |
class Config(object): | |
DEBUG = False | |
SQLALCHEMY_ECHO = False | |
SECRET_KEY = 'dev_key_h8hfne89vm' | |
CSRF_ENABLED = True | |
CSRF_SESSION_LKEY = 'dev_key_h8asSNJ9s9=+' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def imgDownloader(self, url, filename): | |
name_replce = filename.replace(' ', '-') | |
fileext = os.path.splitext(url)[1] | |
full_name = name_replce+fileext | |
if not url: | |
return "" | |
try: | |
filepath = os.path.join("img",full_name) | |
if not os.path.exists("img"): | |
os.makedirs("img") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create new line from text | |
import textwrap | |
from random import randint | |
text = '''<p>Grey round bed with purple bedding The Vig Furniture Opus Modern Round Leather Bed is a unique bed that is perfect for updating your bedroom to a contemporary style BD Essential Gothic Round Bed Frame Only Yatsan Dream Round Bed BD Essential Couture Round Bed Frame Only where to buy a round bed bedroom amazing aiden black round bed modern bedroom furniture home design ideas White suite with circular bed FD Essential Lotus Round Bed Frame Only BD Essential Chic Round Bed Frame Only BD Essential Koala Round Bed Frame Only Trendy Design Circle Bed Ideas Featuring Black Red Colors Leather Amusing Idyllic A Round Bed D Image Stock Photo As Wells As Save To A Lightbox With Circle Bed Mattress Round Mattress Ikea With Magnificent Circle Bed Concept Ikea Sultan Round Bed California King Round Bed Round Bed Ikea Bedroom Appealing Bedroom Idea For Round Bed Design Appealing Bedroom Idea For Round Bed Design Admirable Romantic Round Bed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
from PIL import Image, ImageDraw, ImageFont | |
def work(filename): | |
# Open the original image | |
main = Image.open("img/"+filename) | |
# Create a new image for the watermark with an alpha layer (RGBA) | |
# the same size as the original image |
Custom recipe to get OS X 10.9 Mavericks running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install.
The software selected is software that is "tried and true" --- software I need after any fresh install. I often install other software not listed here, but is handled in a case-by-case basis.
First, you have to enable profiling
> db.setProfilingLevel(1)
Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...