Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Tung Nguyen V. N. ntung

🏠
Working from home
Block or report user

Report or block ntung

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
@zoresvit
zoresvit / uppercase-chap.tex
Last active Dec 17, 2015
LaTeX uppercase chapter title. Compatible with hyperref, no side effects.
View uppercase-chap.tex
% Make chapter titles uppercase is a pain.
% The internal chapter macros must be redefined.
\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
@olivierobert
olivierobert / CI Detect Ajax
Created Nov 22, 2012
Code Igniter // Detect and return AJAX / JSON response
View CI Detect Ajax
/** Within the controller method **/
// If this is an ajax request, then return a JSON string
if ( $this->input->is_ajax_request() ):
$this->output->set_content_type('application/json');
$this->output->set_output( json_encode($data) );
endif;
View gist:3910584
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@Ladicek
Ladicek / maven-deploy-sources.sh
Created Jan 7, 2016
deploy *-sources.jar to internal Maven repository
View maven-deploy-sources.sh
#!/bin/bash
# successful "mvn clean install" or a variant thereof (e.g. -DskipTests)
# is typically required before running this script
REPOSITORY_ID=...
REPOSITORY_URL=...
mvn clean source:jar
@hartleybrody
hartleybrody / Javascript Variable Scoping.md
Last active Feb 3, 2019
Variable scoping in Javascript can be confusing so I set out to make notes of the basic rules so that I can reference them later. Hope these are useful to others, happy to talk pull requests for corrections.
View Javascript Variable Scoping.md

Javascript has two kinds of scope:

  1. Local (inside a function)
  2. Global (outside a function)

The var Keyword

  • Using the var keywords creates the variable in the current scope
    • If the current scope is global, then var is unnecessary (see below)
    • If the current scope is local, then you’re creating a local variable in the current scope
  • If you don’t use var, then Javascript goes up the “scope chain” to see if it’s already been declared
@aeischeid
aeischeid / ErrorController.groovy
Last active May 28, 2019
Alternate grails controller template and url mapping for adding a scaffolded JSON API
View ErrorController.groovy
package gvl
import grails.converters.JSON
class ErrorController {
// Forbidden
def error403() {
withFormat {
html { render(view: 'error403') }
@js1972
js1972 / write_file.groovy
Created May 16, 2014
How to write content to a new file (overwrite if already existing) in Groovy.
View write_file.groovy
//
// Write the mock request payload to a file for checking later...
// newWrite() is the important it to ensure you get a *new* file each time.
//
def filename = "C:\\MyScratchFolder\\soapUI projects\\Testing\\procon\\mock_po_activity_request.xml"
def file = new File(filename)
def w = file.newWriter()
w << mockRequest.requestContent
w.close()
@bennadel
bennadel / angularjs-modals.htm
Created Mar 23, 2015
Creating A Simple Modal System In AngularJS
View angularjs-modals.htm
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Creating A Simple Modal System In AngularJS
</title>
<link rel="stylesheet" type="text/css" href="./demo.css"></link>
@lukauskas
lukauskas / parse_sbml_stoichiometry.py
Last active Sep 28, 2019
Parse SBML stoichiometry matrix
View parse_sbml_stoichiometry.py
from __future__ import print_function
import libsbml
import argparse
def _parser():
parser = argparse.ArgumentParser(description="Parse stoichiometry matrix of SBML file")
parser.add_argument('file', metavar="filename", type=argparse.FileType('r'),
help="Filename of SBML file to parse")
@stefansundin
stefansundin / extract-attachments.py
Last active Oct 30, 2019
Extract attachments from emails that Gmail doesn't allow you to download. This is dumb. Please use Python >= 3.4.
View extract-attachments.py
#!/usr/bin/env python3
# Get your files that Gmail block. Warning message:
# "Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled."
# Based on: https://spapas.github.io/2014/10/23/retrieve-gmail-blocked-attachments/
# Instructions:
# Go to your emails, click the arrow button in the top right, "Show original", then "Download Original".
# Move the files to the same directory as this program, then run it.
import email
You can’t perform that action at this time.