Skip to content

Instantly share code, notes, and snippets.

View martanto's full-sized avatar
👋
Hai!

Martanto martanto

👋
Hai!
  • Bandung, Indonesia
  • 19:55 (UTC +07:00)
View GitHub Profile
@martanto
martanto / vhost
Created April 7, 2020 13:16
Laravel in subdirectory (Nginx)
server {
listen 80;
server_name test.test;
root /storage/web/test;
location /2018 {
alias /storage/web/test/2018/public;
<?php
class User
{
public $firstName = 'Bob';
protected $attributes = [
'firstName' => 'Anto',
];
@martanto
martanto / date_range.php
Last active March 30, 2020 01:46
using times() method to create a list of next 7 days using the Carbon instance
<?php
use Illuminate\Support\Collection;
$nextWeek = Collection::times(7, function ($index) {
return \Carbon\Carbon::now()->addDay($index);
});
@martanto
martanto / transfer_file_multithreading.py
Created March 7, 2020 12:53
Transfer file multithreading
import os
import shutil
from multiprocessing.dummy import Pool as ThreadPool
from tqdm import tqdm
df['image'] = df['_id'].apply(lambda x:x+".jpg")
path = df['image'].tolist()
def move_file(pth):
shutil.move("/content/netaporter_gb/"+pth, "/content/netaporter_gb_images/"+pth)
@martanto
martanto / requests_with_bearer_token.py
Created March 7, 2020 12:51
Requests with bearer token
import requests
auth_token='kbkcmbkcmbkcbc9ic9vixc9vixc9v'
hed = {'Authorization': 'Bearer ' + auth_token}
data = {'app' : 'aaaaa'}
url = 'https://api.xy.com'
response = requests.post(url, json=data, headers=hed)
print(response)
print(response.json())