Skip to content

Instantly share code, notes, and snippets.

View dac09's full-sized avatar

Daniel Choudhury dac09

View GitHub Profile
@dac09
dac09 / xmlparser.py
Created November 12, 2013 13:39
Parsing XML with BeautifulSoup
from bs4 import BeautifulSoup as bs
import sys
f = open('1.xml').read()
soup = bs(f)
# print(soup.prettify()
errorcode = soup.find_all("errorcode")
try:
@dac09
dac09 / view-enter.less
Last active December 28, 2015 17:49
Using ng-animate for animating views (fade in/out eg)
// --------- LESS ------------
.view-enter.ng-enter{
.transition(0.4s ease-in-out all);
opacity:0;
&.ng-enter-active{
opacity:1;
}
}
// ------- Samething in css -----------
@dac09
dac09 / Gruntfile.js
Created November 19, 2013 01:27
Yeoman less grunt. grunt-contrib-less within usual yeoman gruntfile.
// Generated on 2013-11-17 using generator-angular 0.6.0-rc.1
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
@dac09
dac09 / gist:7824307
Created December 6, 2013 14:04
Configuring ffmpeg for vp9 (for some reason vp9 encoder doesn't appear though)
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc \
--enable-libmp3lame \
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --prefix=/usr/local
@dac09
dac09 / Node-mysql
Created February 28, 2014 00:26
Node mysql table create and insert example
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'mysql'
});
connection.connect();
connection.query('CREATE TABLE test.table1(Col1 VARCHAR(10), Col2 VARCHAR(50))', function(err, rows, fields) {
@dac09
dac09 / CapitalCase to camelCase
Created September 10, 2014 00:01
Recursively convert object keys from CapitalCase to camelCase
function camelCase(input) {
return input.charAt(0).toLowerCase() + input.slice(1);
}
function allCapitalCasetoCamelCase(obj) {
var output = {};
for (i in obj) {
if ((Object.prototype.toString.apply(obj[i]) === '[object Object]') || (Object.prototype.toString.apply(obj[i]) === '[object Array]') ) {
output[camelCase(i)] = allCapitalCasetoCamelCase(obj[i]);
} else {
@dac09
dac09 / karma.conf.js
Created October 3, 2014 01:52
Karma config with karma-html-reporter
// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],
@dac09
dac09 / provide_constant.js
Created October 7, 2014 23:03
Constants in Jasmine unit tests
describe('Test', function() {
beforeEach(function() {
module('App', function($provide) {
$provide.constant('CSRF_TOKEN', 'MOCK_CONSTANT'); // <= mock your constant
});
});
// Tests go here
@dac09
dac09 / Move git tag
Last active August 29, 2015 14:15
Move git tag if it exists
#Do this before the new commit
tag=$(git tag -l --contains HEAD)
# -- After the commit --
if [[ -n $tag ]]; then
echo "Tag found, moving it"
git tag -d $tag
git tag $tag
fi
@dac09
dac09 / Nginx proxy route config
Created February 23, 2015 23:10
Nginx config for proxying routes
location ^~ /blog {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}