Skip to content

Instantly share code, notes, and snippets.

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

Kurnia Muhamad omkz

🏠
Working from home
View GitHub Profile
@omkz
omkz / admin.py
Created October 11, 2012 10:21
URLField admin widget with View Link button
"""admin.py"""
from django.contrib import admin
from django.contrib.admin.widgets import AdminURLFieldWidget
from django.db.models import URLField
from django.utils.safestring import mark_safe
from myapp.models import MyModel
class URLFieldWidget(AdminURLFieldWidget):
def render(self, name, value, attrs=None):
@omkz
omkz / admin.py
Created October 11, 2012 19:25
remove whitespace pada django admin field
from django import forms
from django.contrib import admin
from poll.models import Site
class SiteForm(forms.ModelForm):
class Meta:
model = Site
def clean_name(self):
return self.cleaned_data['name'].strip()
@omkz
omkz / setting.py
Created October 12, 2012 09:48
django error >> Incorrect string value: '\xE2\x84\x83 (1...' for column 'description_fr' at row 1
error ini disebabkan karena collation di mysql menggunakan selain utf-8.
resolve :
================
CARA PERTAMA :
================
All I had to do was put this in settings.py:
'OPTIONS': { 'init_command': 'SET storage_engine=INNODB' }
Then I created the database myself in MySQL with:
@omkz
omkz / altertable.php
Created October 12, 2012 10:19
php - alter all table MySQL - set to utf 8
//digunakan untuk mengubah semua collation ke utf-8 pada table. disini pada tabel oxero.
<?php
// your connection
mysql_connect("localhost","root","root");
mysql_select_db("oxero");
// convert code
$res = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_array($res))
@omkz
omkz / fix.txt
Created October 17, 2012 07:45
Drupal - How to fix WARNING: You are not using an encrypted connection
chown www-data:www-data -R /var/www/drupal(or your drupal web root name)/sites
@omkz
omkz / rgb
Created October 28, 2012 15:29
Converting hex color to RGB
A hex value is just RGB numbers represented in hexadecimal. So you just have to take each pair of hex digits and convert them to decimal.
Example:
#FF6400 = RGB(0xFF, 0x64, 0x00) = RGB(255, 100, 0)
@omkz
omkz / LargestArray.java
Created October 28, 2012 15:32
LargestArray
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package omenk;
/**
*
* @author omenk
*/
@omkz
omkz / Fibonacci.java
Created October 28, 2012 15:33
Fibonacci
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package omenk;
/**
*
* @author omenk
*/
@omkz
omkz / BilanganPrima.java
Created October 28, 2012 15:34
BilanganPrima
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package omenk;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
@omkz
omkz / Multiplication.java
Created October 29, 2012 14:50
Multiplication
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package omenk;
/**
*
* @author omenk
*/