Skip to content

Instantly share code, notes, and snippets.

View binfeng's full-sized avatar
🎯
Focusing

Alex binfeng

🎯
Focusing
  • UIUC
  • Urbana-Champaign
View GitHub Profile
@binfeng
binfeng / xpath_soup.py
Created June 29, 2020 21:48 — forked from ergoithz/xpath_soup.py
Generate unique XPATH for BeautifulSoup element
#!/usr/bin/python
# -*- coding: utf-8 -*-
def xpath_soup(element):
# type: (typing.Union[bs4.element.Tag, bs4.element.NavigableString]) -> str
"""
Generate xpath from BeautifulSoup4 element.
:param element: BeautifulSoup4 element.
:type element: bs4.element.Tag or bs4.element.NavigableString
@binfeng
binfeng / imagenet1000_clsidx_to_labels.txt
Created July 5, 2020 04:13 — forked from yrevar/imagenet1000_clsidx_to_labels.txt
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@binfeng
binfeng / psql-error-fix.md
Last active July 8, 2020 02:19 — forked from AtulKsol/psql-error-fix.md
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

@binfeng
binfeng / alexa.py
Created July 9, 2020 04:36 — forked from masnun/alexa.py
Python One-liner to get your site's Alexa Rank
#!/usr/bin/env python
import urllib, sys, bs4
print bs4.BeautifulSoup(urllib.urlopen("http://data.alexa.com/data?cli=10&dat=s&url="+ sys.argv[1]).read(), "xml").find("REACH")['RANK']
@binfeng
binfeng / appSwitcher.js
Created July 19, 2020 22:07
Linux cinnamon remove minimized window from alt tab switcher
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Lang = imports.lang;
const Clutter = imports.gi.Clutter;
const St = imports.gi.St;
const Meta = imports.gi.Meta;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
const Cinnamon = imports.gi.Cinnamon;
@binfeng
binfeng / cloudSettings
Created July 21, 2020 05:46
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-07-21T05:46:34.873Z","extensionVersion":"v3.4.3"}
{"lastUpload":"2020-07-21T05:46:34.873Z","extensionVersion":"v3.4.3"}