Skip to content

Instantly share code, notes, and snippets.

@cucxabeng
cucxabeng / disable_strict_mode_mac_homebrew.md
Created April 6, 2017 15:48
Config disable strict SQL mode for a Homebrew-installed MySQL server
  1. Find config file:
mysqld --help --verbose | grep my.cnf

In my case, it's locate at: /usr/local/etc/my.cnf, show content and find config directory path.

  1. Create new file at this path:
/usr/local/etc/my.cnf.d/disable_strict_mode.cnf
@remarkablemark
remarkablemark / draggable-example.js
Created December 17, 2016 04:13
Basic draggable example using vanilla JavaScript.
'use strict';
/**
* Makes an element draggable.
*
* @param {HTMLElement} element - The element.
*/
function draggable(element) {
var isMouseDown = false;

Notes

  • This code handles any JS runtime error during rendering React components. Without this handling, once an error occurs, whole component tree is damaged and can't be used at all. With this handling, nothing will be rendered in production environment (error span in dev env.) + in production the error is logged to Sentry (if you are not using it just delete related code)
  • This is basicaly a workaround for proposed feature in React core - described in Issue: facebook/react#2461
  • Works for all variants of Component creation - React.createClass, extending React.Component and also stateless functional components.
  • To get this work, just put this snippet into your entry js file. Then it will work in whole application.
  • Also supporting React Hot Reload!
  • If you find this useful, please retweet https://twitter.com/Aldredcz/status/744650159942995968 :)

Ideas

  • specify custom error renderer (global / per component, e.g. by implementing method renderOnError() in a comp
@tj
tj / update.js
Last active April 29, 2023 14:53
shouldComponentUpdate utility
let rows = {}
export default function(props = [], state = []) {
return function(target) {
const proto = Object.create(target.prototype)
proto.shouldComponentUpdate = function(newProps, newState) {
let id = (this._update_id = this._update_id || Math.random())
@renehamburger
renehamburger / slimdown.js
Last active September 4, 2023 07:55
slimdown.js
'use strict';
/**
* Javascript version of https://gist.github.com/jbroadway/2836900
*
* Slimdown - A very basic regex-based Markdown parser. Supports the
* following elements (and can be extended via Slimdown::add_rule()):
*
* - Headers
* - Links
@joecampo
joecampo / Connecting PHP 5.6 to MSSQL.md
Last active June 4, 2022 14:20
Connecting PHP 5.6 to MSSQL - Ubuntu (Debian) w/ Apache
@rcullito
rcullito / gist:cd4513766e112387b9c8
Created May 6, 2014 01:51
ElasticSearch Fuzzy Query, Favor Exact Matches
{
"query": {
"bool": {
"should": [
{
"match": {
"_all": search_term
}
},
{
@shadowhand
shadowhand / .gitconfig
Created December 15, 2011 20:33
Complex Git Aliases
[alias]
co = checkout
st = status
ci = commit
rb = rebase
rank = shortlog -sn --no-merges
amend = commit --amend -C HEAD
vr = !sh -c \"git svn fetch && git svn rebase\"
vc = !sh -c \"git vr && git svn dcommit\"
ex = !sh -c \"git checkout-index -a -f --prefix=$1\"
#!/bin/bash
while read oldish newish ref; do
branch=$(echo "$ref" | cut -d"/" -f3-)
done
case "$branch" in
"live")
git --work-tree=/var/www/dylanstestserver.com/ checkout -f $branch
echo 'Changes pushed live.'
;;
esac
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt