Skip to content

Instantly share code, notes, and snippets.

@jhrr
jhrr / access_from_web.md
Created August 8, 2018 11:14 — forked from jasperf/access_from_web.md
MySQL Commands to create users, database, password and grant necessary privileges from the command line
mysql> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'localhost' WITH GRANT OPTION;
mysql> CREATE USER 'user_name'@'%' IDENTIFIED BY 'password';

mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'%' WITH GRANT OPTION;

{% block scripts %}
{{ block.super }}
<script>
$('.datepicker').datepicker({
format : 'MM dd',
}).on('show', function() {
const dateText = $('.datepicker-days .datepicker-switch').text();
const dateTitle = dateText.replace(/[0-9]/g, '');
$('.datepicker-days .datepicker-switch').text(dateTitle);
$('.dow').hide();
@jhrr
jhrr / gist:21e83ec6eec7afcaf17823baea58b400
Last active March 20, 2018 15:52 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
$.expr[':'].regex = (elem, index, match) => {
const matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
@jhrr
jhrr / trello-card-numbers.js
Created October 11, 2016 14:41
Bookmarklet to toggle trello card numbers
javascript:!function(){var o=$(".card-short-id");o.each(function(){$(this).text($(this).text().replace("#","").replace("#","").replace("N.%C2%BA ", ""))});o.hasClass("hide")?o.removeClass("hide").css({"font-weight":"normal","font-size":".8em","margin-right":"5px",padding:"2.3px 6px","background":"white","border-radius":"10px","border":"1px solid grey","color":"red"}):o.addClass("hide")}();
@jhrr
jhrr / vertical-align.css
Last active February 27, 2017 11:44
Vertically align anything
.u-vertical-align {
position: relative;
top: 50%;
transform: perspective(1px) translateY(-50%);
}
In [1]: l1 = [1]
In [2]: l2 = [1, 2]
In [3]: a, = l1
In [4]: a
Out[4]: 1
In [5]: b, = l2
# Put in const.py...:
class _const:
class ConstError(TypeError): pass
def __setattr__(self,name,value):
if self.__dict__.has_key(name):
raise self.ConstError, "Can't rebind const(%s)"%name
self.__dict__[name]=value
import sys
sys.modules[__name__]=_const()
;; https://coldnew.github.io/blog/2013/11-16_d2f3a/
;; https://github.com/kuanyui/.emacs.d/blob/master/rc/rc-basic.el#L102
;; ============================================
;; Coldnew's Font Size Conf for Org-Table
;; ============================================
;; 特殊字型設定
(when (window-system)
(defvar emacs-english-font "DejaVu Sans Mono"
"The font name of English.")
.grid {
display: flex;
flex-flow: row wrap;
}
.grid > * {
flex-basis: 10em;
flex-grow: 1;
}