Skip to content

Instantly share code, notes, and snippets.

View dukenmarga's full-sized avatar

Duken Marga dukenmarga

View GitHub Profile
@dukenmarga
dukenmarga / newton_raphson.c
Created August 19, 2014 04:43
Newton Raphson Method
/*
* program untuk mencari solusi persamaan
* dari fungsi x^2 + x = cos(x)
* dengan menggunakan metode raphson
* f(x) = x^2 + x - cos(x)
* f(x)' = 2x + 1 + sin(x)
* @author Duken Marga
*/
#include <stdio.h>
@dukenmarga
dukenmarga / bisecton_method.c
Created August 19, 2014 04:43
Bisection Method
/*
* metode numerik dengan bisection method
* author : duken marga
*/
#include <stdio.h>
#include <math.h>
#define EPSILON 10E-10
#define PHI 3.141592654
@dukenmarga
dukenmarga / babylon.cpp
Created August 19, 2014 04:45
Babylon Algorithim to calculate square root of a number
/*
compile with g++ (MinGW)
ex : g++ square.cpp -o square
@author Duken Marga
dukenmarga at gmail dot com
*/
#include <iostream>
#include <iomanip>
using namespace std;
@dukenmarga
dukenmarga / ubuntu.sh
Created August 19, 2014 04:45
Various command in Ubuntu
#basic
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install package-name
#clean cache
sudo apt-get clean && sudo apt-get update
#upgrade version
sudo apt-get install update-manager-core
sudo do-release-upgrade
@dukenmarga
dukenmarga / force_install.sh
Created August 19, 2014 04:46
force install when dependencies meet cyclic problem
dpkg --force-depends --install /home/duken/libc6-i686_2.11.1-0ubuntu7.8_i386.deb /home/duken/findutils_4.4.2-1ubuntu1_i386.deb
@dukenmarga
dukenmarga / simple_sqlite.sql
Created August 19, 2014 04:46
create database and table in sqlite
CREATE TABLE IF NOT EXISTS author (
`id_author` INT NOT NULL,
`username` VARCHAR(45) NOT NULL ,
`password` VARCHAR(32) NOT NULL ,
`email` VARCHAR(60) NOT NULL ,
`first_name` VARCHAR(45) NULL ,
`last_name` VARCHAR(45) NULL ,
PRIMARY KEY (`id_author`) );
CREATE TABLE IF NOT EXISTS post (
@dukenmarga
dukenmarga / crud.php
Created August 19, 2014 04:47
Simple Crud in PHP
<?php
function insert($table = '1', $values = array(' ' => ' ')){
if (is_array($values)){
foreach($values as $value){
$field .= "$value,";
}
}
$val = str_replace(',', '', $val);
$query = "INSERT INTO $table VALUES ($val)";
@dukenmarga
dukenmarga / wordpress.htaccess
Created August 19, 2014 04:48
Wordpress htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
##################################################
# Redirect to http://duken.info :)
RewriteCond %{HTTP_HOST} ^duken-mt\.co\.cc
RewriteRule ^(.*)$ http://duken.info/$1 [R=permanent,L]
@dukenmarga
dukenmarga / profile_picture_twitter.php
Created August 19, 2014 04:49
get profile picture from twitter
<?php
/**
* @author Duken Marga
* dukenmarga [at] gmail.com
* Get profile picture from twitter
* You can clean up and optimize the code
**/
getImageTwitter('dukenmarga');
function getImageTwitter($account = 'dukenmarga'){
@dukenmarga
dukenmarga / month_to_string.php
Created August 19, 2014 04:49
convert month number into month string
<?php
$month = 8;
print date("M", mktime(0, 0, 0, $month));
?>