Skip to content

Instantly share code, notes, and snippets.

View ilyasahsan123's full-sized avatar

ilyas ahsan ilyasahsan123

  • Jakarta, Indonesia
  • 12:24 (UTC +07:00)
View GitHub Profile
@ilyasahsan123
ilyasahsan123 / tweet_dumper.py
Created November 17, 2017 02:47 — forked from yanofsky/LICENSE
A script to download all of a user's tweets into a csv
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
@ilyasahsan123
ilyasahsan123 / main.py
Created November 22, 2017 03:14
python get value from rest api
import request
import json
# get top artist with last.fm api
# search on google last.fm api please
def get_artist_name(URL):
data = request.get(URL).text
data = json.loads(data)
top_artist = data["topartists"]["artist"][0]["name"]
@ilyasahsan123
ilyasahsan123 / cheatsheet.md
Created November 22, 2017 06:00 — forked from afandiyusuf/cheatsheet.md
Laravel cheatsheet

First Step

Requirement of laravel

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
@ilyasahsan123
ilyasahsan123 / MenyatakanCinta.py
Created April 3, 2018 14:05
Machine learning sederhana untuk prediksi di terima atau tidak saat menyatakan cinta
# import algoritma logistic regression pada scikit learn
from sklearn.linear_model import LogisticRegression
# membuat variable classifier dengan algoritma logistic regression
clf = LogisticRegression()
# properti yang dibutuhkan pada aplikasi ini mempunyai sebuah array dengan value sebagai berikut
# index 0 : Jarak rumah dalam KM
# index 1 : Level bau ketek (1 - 10)
# index 2 : Jenis kendaraan denga properti 0 = angkot, 1 = motor, 2 = mobil
mysqldump -u [user] -p[user_password] [nama_database] > [nama_file].sql
import datetime
import os
import glob
now = datetime.datetime.now().strftime("%d-%m-%y")
date = now.split("-")
date_of_today = date[0]
db_user = "user"
db_user_password = "user_password"
* 12 * * * cd [python script directory] && /usr/bin/python [python script directory]/backup_database.py
example:
* 12 * * * cd var/www/backup_db/ && /usr/bin/python var/www/backup_db/backup_database.py
no waktu yang di habiskan (detik)
SQL LIKE operator Regex
1 5.0 3.5
2 4.7 3.5
3 4.2 3.3
4 5.0 3.9
5 4.4 3.9
6 4.3 4.2
7 5.6 2.9
8 4.2 3.3
select u.display_name
,s.amount
,u.location
from [bigquery-public-data:stackoverflow.users] u
join (
select s.owner_user_id,
count(*) amount
from [bigquery-public-data:stackoverflow.posts_questions] s
group by s.owner_user_id
) s
select tag
,count(*) number
from(
select SPLIT(q.tags, '|') tag
from [bigquery-public-data:stackoverflow.posts_questions] q
join [bigquery-public-data:stackoverflow.users] u
on q.owner_user_id = u.id
where REGEXP_MATCH(u.location, '(?i)indonesia')
)
group by tag