Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Tuan Nguyen Anh anhtuank7c

🎯
Focusing
Block or report user

Report or block anhtuank7c

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bnoguchi
bnoguchi / enum-access.js
Created May 3, 2011
How to access enumValues in mongoose from a Model or Document
View enum-access.js
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
@rodionmoiseev
rodionmoiseev / gist:2484934
Created Apr 25, 2012
Setting up Play 2.0 in build.gradle
View gist:2484934
apply plugin: 'java'
apply plugin: 'scala'
// For those using Eclipse or IntelliJ IDEA
apply plugin: 'eclipse'
apply plugin: 'idea'
def findPlay20(){
def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
for(playExec in ['play.bat', 'play.sh', 'play']){
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active Oct 18, 2019
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@katowulf
katowulf / gist:4741111
Last active Sep 17, 2019
Firebase security rules for a simple chat room model
View gist:4741111
{
"chat": {
// the list of chats may not be listed (no .read permissions here)
// a chat conversation
"$key": {
// if the chat hasn't been created yet, we allow read so there is a way
// to check this and create it; if it already exists, then authenticated
// user (specified by auth.id) must be in $key/users
@emil2k
emil2k / Connectivity.java
Last active Oct 1, 2019
Android utility class for checking device's network connectivity and speed.
View Connectivity.java
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@arunoda
arunoda / gist:7790979
Last active Oct 17, 2019
Installing SSHPass
View gist:7790979

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

View CorsFilter.php
<?php
App::uses('DispatcherFilter', 'Routing');
class CorsFilter extends DispatcherFilter {
public function beforeDispatch(CakeEvent $event) {
if ($event->data['request']->is('OPTIONS')) {
$event->stopPropagation();
$event->data['response']->header(array(
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created Apr 17, 2014
Git force pull to overwrite local files
View gist:10964772
git fetch --all
git reset --hard origin/master
git pull origin master
@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created Sep 20, 2014
a safe way to upgrade all of your globally-installed npm packages
View npm-upgrade-bleeding.sh
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
View gist:3b19447b304616f18657
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
You can’t perform that action at this time.