Skip to content

Instantly share code, notes, and snippets.

View marcinlawnik's full-sized avatar

Marcin Ławniczak marcinlawnik

View GitHub Profile
@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');
@meigwilym
meigwilym / console.php
Last active March 5, 2024 02:20
Laravel Create User Command
<?php
// routes/console.php
// quickly create an user via the command line
Artisan::command('user:create', function () {
$name = $this->ask('Name?');
$email = $this->ask('Email?');
$pwd = $this->ask('Password?');
// $pwd = $this->secret('Password?'); // or use secret() to hide the password being inputted
\DB::table('users')->insert([
@AtulKsol
AtulKsol / psql-error-fix.md
Last active April 10, 2024 07:41
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@natdm
natdm / goroutines.go
Created July 20, 2016 14:00
Explaining how to make DB calls with goroutines and waitgroups.
//GetTransactionsAndLinesForBidder hits the database 3 times. Let's make that fast.
func (db *DB) GetTransactionsAndLinesForBidder(bidderID int) ([]BidderTransaction, error) {
//Establish a waitgroup. This has 3 functions only. Add, Wait, and Done. You add to the WaitGroup and hit Done when you are
// done with a process. It will stop the function at Wait until the WaitGroup is at 0.
var wg sync.WaitGroup
//Get the transaction 'shell'
trans, err := db.GetTransactionsForBidder(bidderID)
if err != nil {
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@stephen-hill
stephen-hill / install
Last active July 9, 2016 08:27
MariaDB on Ubuntu 14.04 Minimal
# Essential
apt-get update
apt-get upgrade
apt-get install dialog bsdutils software-properties-common
# MariaDB
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
add-apt-repository 'deb http://lon1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main'
apt-get update
apt-get install mariadb-server
@Moollihawkja
Moollihawkja / popup.html
Created July 14, 2015 04:54
Creating a pop up in pure javascript
<!DOCTYPE html>
<html>
<head>
<style>
.popup {
position: fixed;
top: 50vh;
left: 50%;
width:400px;
margin-left: -200px;
@pelsedyr
pelsedyr / qimg_image_conv.cpp
Created April 25, 2015 09:16
Conversion between QImage and Magick::Image. Tested and reliable.
Image* MainWindow::toImage(QImage* qimage)
{
qDebug() << "toImage:" << qimage->width() << qimage->height();
Image *newImage = new Image(Magick::Geometry(qimage->width(), qimage->height()), Magick::ColorRGB(0.5, 0.2, 0.3));
double scale = 1 / 256.0;
newImage->modifyImage();
Magick::PixelPacket *pixels;
Magick::ColorRGB mgc;
@tomzx
tomzx / gist:aa2d9172a1daef15a0ac
Created January 7, 2015 02:41
./gradlew: Permission denied
/home/travis/build.sh: line 175: ./gradlew: Permission denied
Fix by setting the executable flag on your gradlew file.
Either
chmod +x gradlew (on unix systems)
OR
@hroling
hroling / gist:85f36e86d48285f08161
Last active March 28, 2021 02:42
Apache 2.4 SSL config for A+ on SSLLabs.com
OLD stuff. This was not enough for an A+ anymore.