Skip to content

Instantly share code, notes, and snippets.

View mrhieu's full-sized avatar

Hieu Pham mrhieu

View GitHub Profile

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@mrhieu
mrhieu / application.html.erb
Created May 19, 2014 07:15 — forked from collectiveidea/application.html.erb
CSRF token for AJAX POST in Rails 3
<!DOCTYPE html>
<html>
<head>
<title>My Rails App</title>
<%- if protect_against_forgery? -%>
<meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" />
<%- end -%>
<%= javascript_include_tag 'jquery', 'rails' %>
</head>
<body>
@mrhieu
mrhieu / flex.sass
Created October 10, 2014 14:37
Flex layout CSS extracted from Google Polymer 0.4.2
html
[layout]
&[horizontal], &[vertical]
display: -ms-flexbox
display: -webkit-flex
display: flex
&[horizontal][inline], &[vertical][inline]
display: -ms-inline-flexbox
display: -webkit-inline-flex
display: inline-flex
@mrhieu
mrhieu / rest.js
Last active March 27, 2017 14:54
AngularJS: factory that adds restful support to any factory
'use strict';
/**
* @ngdoc service
* @name app.services.service:RestService
*
* @description
* The common service to quickly setup other services to expose a restful-like interface
*
* How to use in a factory
@mrhieu
mrhieu / slack_delete.rb
Created June 21, 2016 06:40 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@mrhieu
mrhieu / nvd3_helper.sass
Last active February 7, 2017 08:07
Collection of handy CSS rules for nvd3 chart (D3.js). By adding class name(s), you will have the desired style applied.
.hide-axis-x
.nvd3 .nv-axis.nv-x path
opacity: 0
.hide-axis-y
.nvd3 .nv-axis.nv-y path
opacity: 0
.dashed-userInteractiveGuideLine
.nvd3 .nv-interactiveGuideLine .nv-guideline
stroke-dasharray: 5,3
@mrhieu
mrhieu / helper.sass
Last active November 2, 2017 19:23
My helper CSS 1.1.1
/* CSS Helper ver 1.1.1 */
/* FLEX from Google Polymer 0.5.2 */
html
[layout]
&[horizontal], &[vertical]
display: -ms-flexbox
display: -webkit-flex
display: flex
@mrhieu
mrhieu / config.js
Created June 1, 2018 12:10 — forked from chodorowicz/config.js
react-storybook samples
/**
* dynamically loading all stories with .stories.js extension
*/
import { configure } from '@kadira/storybook';
require('es6-promise').polyfill();
import 'babel-polyfill';
const stories = require.context('../app/js/components', true, /.stories.js$/);
function loadStories() {
@mrhieu
mrhieu / Gruntfile.js
Created June 6, 2018 08:55
[Medium] Prevent Annoying Template Caching in AngularJS 1.x
...
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'gitinfo',
'clean:server',
'ngconstant',
@mrhieu
mrhieu / generate-ssh-key.sh
Created July 15, 2018 10:08 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa