Skip to content

Instantly share code, notes, and snippets.

View Mavlarn's full-sized avatar

Mavlarn Mavlarn

  • Vantiq
View GitHub Profile

Export HTML table to Excel in AngularJS

myApp.factory('Excel',function($window){
		var uri='data:application/vnd.ms-excel;base64,',
			template='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
			base64=function(s){return $window.btoa(unescape(encodeURIComponent(s)));},
			format=function(s,c){return s.replace(/{(\w+)}/g,function(m,p){return c[p];})};
		return {
// just wrap 'filesizejs.com' as filter.
module
.filter('FileSize', function () {
return function (arg, descriptor) {
var si = {
bits : ["B", "kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
bytes : ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
};
@Mavlarn
Mavlarn / about-me
Created March 11, 2014 16:09
about-me
# RESUME
## Personal Information
----
Name: Mavlarn. Tuohuti (买乌拉江)
Birthday: 1980
Gender: male
Phone: 13810957617
Email: mavlarn@163.com mavlarn@gmail.com
Nation: China
@Mavlarn
Mavlarn / lt-cljs-tutorial.clj
Created January 20, 2014 12:14
An Introduction to ClojureScript for Light Table users Got from https://github.com/swannodette/lt-cljs-tutorial.
;; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; An Introduction to ClojureScript for Light Table users
;; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Basics
;; ============================================================================
;; To begin open the command pane (type Control-SPACE), Add Connection, select
;; Light Table UI. Once connected you can evaluate all the forms in this file
;; LOAD ME WITH
;; (load-file "/home/john/hobby-code/require-all-snippet.clj")
;; This file conditions a repl in various ways that I do all the time.
;; Firstly we want to 'require' all the namespaces on the classpath
;; This ensures that find-doc and the like will work
(require 'clojure.contrib.find-namespaces)
;; Some namespaces may fail to load, so catch any exceptions thrown
@Mavlarn
Mavlarn / CreateJarFile.java
Created January 1, 2014 05:28
Create java package in code.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
public class CreateJarFile {
public static int BUFFER_SIZE = 10240;
protected void createJarArchive(File archiveFile, File[] tobeJared) {
@Mavlarn
Mavlarn / Git tutorial
Created November 29, 2013 05:37
git tutorial
# Git tutorial #
This tutorial will show you some basic usgae of git, including how to create a git repository, commit, push to local and remote repository. And also show you how to use with more than one remote repository,
## Working in local repository ##
-------
At first, we will create a git repository in our local and working on that. We will create a project with git and add/modify some files.
At first, create a repository:
```bash
@Mavlarn
Mavlarn / zk_client.c
Last active December 22, 2015 04:58
Workable C client code for zookeeper ensemble.
/**
* Workable C client code for zookeeper ensemble under zoopiter management.
* Include async and sync mode, for async mode, should use some synchronization method like 'lock'.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <zookeeper/zookeeper.h>
@Mavlarn
Mavlarn / VMMonitor.java
Created April 2, 2013 03:23
Monitor a VM process in current machine with JMX, attach API.
package my.test;
import java.io.File;
import java.io.IOException;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.util.HashSet;
# -*- coding:utf-8 -*-
from io.socket import IOCallback
from java.util.concurrent.locks import ReentrantLock
from io.socket import SocketIO
# it use socket.io java client of: https://github.com/Gottox/socket.io-java-client
class BlockingSocketIO(IOCallback):
respMsg = "";