Skip to content

Instantly share code, notes, and snippets.

View tiendq's full-sized avatar
🌳
Code for a Living

Tien Do tiendq

🌳
Code for a Living
View GitHub Profile
@tiendq
tiendq / VSCode
Last active August 8, 2020 09:29
VSCode.settings.json
/*
Atom One Dark Theme
C/C++
CMake
Debugger for Chrome
DotENV
ESLint
Markdown All in One
vscode-icons
*/
@tiendq
tiendq / css_debugger.js
Created November 5, 2017 04:27
CSS debugger
[].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
// https://davidwalsh.name/essential-javascript-functions
let getAbsoluteUrl = (function () {
let a;
return function (url) {
if (!a)
a = document.createElement('a');
a.href = url;
return a.href;
import React from "react";
const numeral = require("numeral");
const BACKSPACE_KEY = 8, TAB_KEY = 9, ENTER_KEY = 13, NUMBER_0 = 48, NUMBER_9 = 57;
class KilometerInput extends React.Component {
constructor() {
super();
this.keyPressHandler = this.keyPressHandler.bind(this);
@tiendq
tiendq / osx-mongodb-rlimits-fix.md
Created March 7, 2016 14:02 — forked from tamitutor/osx-mongodb-rlimits-fix.md
Fix Mongodb "soft rlimits" Warning On Mac OS X (Yosemite)

If you are seeing Mongo soft rlimits warnings in your logs, or a WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 when you login to mongo shell via mongo from the commandline, or any mysterious/unexplained mongo connection errors... follow this how-to exactly and it will resolve the issue for you.

(Source of this how to found at basho/basho_docs#1402)

First file: sudo vi /Library/LaunchDaemons/limit.maxfiles.plist

...containing:

/* Dealing with long words in CSS
https://justmarkup.com/log/2015/07/31/dealing-with-long-words-in-css */
.hyphenate {
overflow-wrap: break-word;
word-wrap: break-word;
-webkit-hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
@tiendq
tiendq / selectedvalue.js
Last active August 29, 2015 14:07
Get selected value/text
// I saw a sample code like this, but don't do it.
function() {
var selectId = "mySelectList";
try {
var options = document.getElementById(selectId).options;
for (var i = 0;i < options.length;i++){
if(options[i].selected) {
return options[i].value;
}
}
@tiendq
tiendq / jqueryplugin.js
Created October 13, 2014 07:29
jQuery plugin example.
// Author: Tien Do
(function ($) {
$.fn.redify = function(options) {
// Extend our default options with those provided.
// Note that the first argument to extend is an empty
// object – this is to keep from overriding our "defaults" object.
var settings = $.extend({}, $.fn.redify.defaults, options);
return this.css({
@tiendq
tiendq / gist:45f1fd5c0d1c2d7c5fe6
Created May 29, 2014 02:20
Pixelate an image
// http://notes.ericwillis.com/2009/11/pixelate-an-image-with-csharp/
private static Bitmap Pixelate(Bitmap image, Rectangle rectangle, Int32 pixelateSize)
{
Bitmap pixelated = new System.Drawing.Bitmap(image.Width, image.Height);
// make an exact copy of the bitmap provided
using (Graphics graphics = System.Drawing.Graphics.FromImage(pixelated))
graphics.DrawImage(image, new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
@tiendq
tiendq / InlineBlock.html
Created July 31, 2013 04:10
How to fight inline blocks space and heigh 100%
<!doctype html>
<html>
<head>
<style>
.parent {
width: 600px;
box-sizing: border-box;
margin: 0;
padding: 0;
background-color: yellow;