Skip to content

Instantly share code, notes, and snippets.

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

Yuda Sukmana ydatech

🏠
Working from home
View GitHub Profile
@ydatech
ydatech / gist:769ccf15b3ef88a19df7ff8571c6f22b
Created August 10, 2016 03:43 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@ydatech
ydatech / stateful.php
Last active October 29, 2017 12:58
Stateless vs Stateful : Tutorial Yudasukmana.web.id
<?php
// Contoh stateful
session_start();
// Dapatkan informasi username dari query parameter kemudian simpan di session
// Request pertama kita mengirimkan informasi username melalui query paramater
// http://localhost:8080/stateful.php?username=ydatech
// Dalam request kedua dan seterusnya kita tidak perlu lagi mengirimkan info username
// melalui query parameter karena sudah tersimpan di session
@ydatech
ydatech / git.sh
Created September 3, 2016 12:56
Setting Git
#masuk ke direktori barbek
cd barbek
#Inisiasi local repository git baru di derektori barbek
git init
#Tambah kan semua file yang ada di folder/derektori barbek
#kecuali folder/file yang terdaftar di .gitinore
git add .
@ydatech
ydatech / db.php
Created September 4, 2016 04:03
Connect MySQL Database barbek Yii2 t
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=barbek',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
];
@ydatech
ydatech / user.sh
Created September 4, 2016 09:55
Create table user using yii migration
# buat migration untuk table baru bernama user: php yii migrate/create create_user_table
# untuk membuat kolom beserta tipe data kita bisa menggunakan parameter --fields
# kolom primary key yaitu id akan secara otomatis digenerate tanpa harus mendefinisikannya di parameter --fields
php yii migrate/create create_user_table --fields="username:string(20):notNull:unique,password:string(255):notNull,email:string(255):notNull,status:smallInteger(1):defaultValue(0),dibuat_pada:integer(10),diperbarui_pada:integer(10)"
<?php
use yii\db\Migration;
/**
* Handles the creation for table `user`.
*/
class m160904_094638_create_user_table extends Migration
{
/**
@ydatech
ydatech / kontak.sh
Created September 4, 2016 12:46
Command to create kontak table
# membuat migration file untuk table baru bernama kontak beserta kolomnya
php yii migrate/create create_kontak_table --fields="user_id:integer:notNull:foreignKey(user),nama:string(255):notNull,no_hp:string(15),whatsapp:string(15),telegram:string(20),line:string(20),bbm:string(10),dibuat_pada:integer(10),diperbarui_pada:integer(10)"
@ydatech
ydatech / m160904_124655_create_kontak_table.php
Created September 4, 2016 12:51
Migration kontak table php
<?php
use yii\db\Migration;
/**
* Handles the creation for table `kontak`.
* Has foreign keys to the tables:
*
* - `user`
*/
@ydatech
ydatech / provinsi.sh
Last active September 4, 2016 13:26
Provinsi Migration command
# membuat database migration untuk tabel provinsi
php yii migrate/create create_provinsi_table --fields="nama:string(50)"
@ydatech
ydatech / csv.sh
Last active October 5, 2016 09:05
Install CSV library
# Install league/csv
composer require league/csv