Skip to content

Instantly share code, notes, and snippets.

@aalipar13
aalipar13 / pngquant-fix.txt
Created August 23, 2018 10:42
pngquant binary doesn't seem to work correctly
# node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
$ sudo apt-get install libpng-dev
$ npm install -g pngquant-bin
@aalipar13
aalipar13 / mysql-constraint.sql
Created August 28, 2018 06:05
Cannot truncate a table referenced in a foreign key constraint
# Cannot truncate a table referenced in a foreign key constraint
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE <table>;
SET FOREIGN_KEY_CHECKS=1;
import json
import requests
from bs4 import BeautifulSoup
import sys
r = requests.get('https://www.instagram.com/kryzzzie/')
soup = BeautifulSoup(r.text, 'lxml')
script = soup.find('script', text=lambda t: t.startswith('window._sharedData'))
page_json = script.text.split(' = ', 1)[1].rstrip(';')
import requests
from bs4 import BeautifulSoup
user = 'LazadaPhilippines'
url = 'https://www.facebook.com/'+ user
response = requests.get(url)
soup = BeautifulSoup(response.content)
f = soup.find('div', attrs={'class': '_4-u3 _5sqi _5sqk'})
likes=f.find('span',attrs={'class':'_52id _50f5 _50f7'}) #finding span tag inside class
print(likes.text)
import requests
from bs4 import BeautifulSoup
headers = requests.utils.default_headers()
headers.update({
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0',
})
url = 'https://www.costco.com/'
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.content)
@aalipar13
aalipar13 / default-with-ssl
Last active October 2, 2018 02:50
nginx sample site with ssl
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
mysql> USE mysql;
mysql> UPDATE user SET authentication_string=PASSWORD("linuxconfig.org") WHERE User='root';
mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
@aalipar13
aalipar13 / routes.php
Created November 14, 2018 02:50
Export Laravel Routes in CSV format
/**
* Generate a CSV of all the routes
*/
Route::get('r', function()
{
header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename="routes.csv"');
$routes = Route::getRoutes();
$fp = fopen('php://output', 'w');
@aalipar13
aalipar13 / gist:287d94240ceebd5bc7a569456ca9906a
Last active August 20, 2019 02:12
Laravel - Create User
php artisan tinker
$user = new App\User();
$user->password = 'passw0rt123';
$user->email = '[email protected]';
$user->name = 'kiminonawa';
$user->save();
<?php
$json = file_get_contents('json.txt');;
$array = json_decode($json, true);
$newArray = [];
foreach ($array as $value)
{