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
@ntung
ntung / CI Detect Ajax
Created May 5, 2017 — forked from olivierobert/CI Detect Ajax
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;
@ntung
ntung / CI Detect Ajax
Created May 5, 2017 — forked from olivierobert/CI Detect Ajax
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;
@ntung
ntung / get_content.groovy
Created Apr 25, 2017 — forked from kdabir/get_content.groovy
get content from url and write to a file in groovy
View get_content.groovy
// saving from url to a file (append)
new File("output.xml") << new URL ("http://some.url/some/path.xml").getText()
@ntung
ntung / write_file.groovy
Created Jan 27, 2017 — forked from js1972/write_file.groovy
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()
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")
@ntung
ntung / doi2bib.py
Created Feb 26, 2016 — forked from jrsmith3/doi2bib.py
Python method to access crossref.org DOI bibtex metadata resolver
View doi2bib.py
import requests
def doi2bib(doi):
"""
Return a bibTeX string of metadata for a given DOI.
"""
url = "http://dx.doi.org/" + doi
headers = {"accept": "application/x-bibtex"}
You can’t perform that action at this time.