Skip to content

Instantly share code, notes, and snippets.

SELECT
title, COUNT(title)
FROM
cities
GROUP BY
title
HAVING
COUNT(title) > 1;
DELETE t1 FROM cities t1
<?php
$arr = [
['date' => '2019-07-31', 'total' => 4],
['date' => '2019-08-04', 'total' => 6],
['date' => '2019-08-05', 'total' => 7]
];
$result = [];
foreach ($arr as $k => $item) {
<?php
$json = file_get_contents('json.txt');;
$array = json_decode($json, true);
$newArray = [];
foreach ($array as $value)
{
@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();
@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');
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 / 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.
#
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)
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 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(';')