Skip to content

Instantly share code, notes, and snippets.

View quxiaofeng's full-sized avatar
🎯
Focusing

Xiaofeng Qu quxiaofeng

🎯
Focusing
View GitHub Profile
@cburgdorf
cburgdorf / xor_keras.py
Last active November 18, 2020 11:23
Comparing XOR between tensorflow and keras
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
target_data = np.array([[0],[1],[1],[0]], "float32")
model = Sequential()
model.add(Dense(32, input_dim=2, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
@ArchRobison
ArchRobison / gist:d3601433d160b05ed5ee
Created June 25, 2014 17:56
patch to LLVM 3.3 to work around Intel VTune Amplifier bug. For Julia, apply to julia/deps/llvm-3.3/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
--- IntelJITEventListener.cpp.orig 2014-05-15 13:45:30.079547337 -0500
+++ IntelJITEventListener.cpp 2014-05-15 13:46:43.647359854 -0500
@@ -174,6 +174,11 @@
FunctionMessage.line_number_table = 0;
}
+#define AMPLIFIER_BUG_WORKAROUND 1
+#if AMPLIFIER_BUG_WORKAROUND
+ for( unsigned i=FunctionMessage.line_number_size; i-->0; )
+ FunctionMessage.line_number_table[i].LineNumber = i>0 ? FunctionMessage.line_number_table[i-1].LineNumber : 0;
@randName
randName / FCD.py
Created June 6, 2014 15:06
Fast Circle Detection using Gradient Pair Vectors
#!/usr/bin/env python2
import numpy as np
import cv2 as cv
def FCD( src, mask ):
A_THRESH = [ 2, 1 ]
sobel_x = cv.Sobel( src, cv.CV_32F, 1, 0, ksize = 5 )
@amirmasoudabdol
amirmasoudabdol / read_csv.c
Created May 19, 2014 09:59
To read the CSV file in C
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void read_csv(int row, int col, char *filename, double **data){
FILE *file;
file = fopen(filename, "r");
int i = 0;
@luispedro
luispedro / pdio.py
Last active March 22, 2019 14:05
Save & load from a pandas DataFrame/Series
import numpy.lib
import numpy as np
import pandas as pd
import cPickle as pickle
def save_pandas(fname, data):
'''Save DataFrame or Series
Parameters
----------
@christianp
christianp / id_mathjax_plugin.js
Created August 29, 2013 10:44
IntenseDebate MathJax plugin. Paste it into http://intensedebate.com/pluginEditor/ There's a bug in IntenseDebate at the moment - backslashes are stripped out of newly-posted comments, which knacks TeX thoroughly. Reloading the page gets you the correct text, slashes included.
var id_mathjax_plugin;
(function() {
var mjp = id_mathjax_plugin = {
load_mathjax: function() {
function e(e){var t='.MathJax .mn {background: inherit;} .MathJax .mi {color: inherit;} .MathJax .mo {background: inherit;}',n=e.createElement('style');n.innerText=t;try{n.textContent=t}catch(r){}e.getElementsByTagName('body')[0].appendChild(n);var i=e.createElement('script'),s;i.src='https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js',i.type='text/javascript',s='MathJax.Hub.Config({skipStartupTypeset:true,tex2jax:{inlineMath:[[\'$\',\'$\']],displayMath:[[\'\\\\[\',\'\\\\]\']],processEscapes:true}});MathJax.Hub.Startup.onload();',window.opera?i.innerHTML=s:i.text=s,e.getElementsByTagName('head')[0].appendChild(i)}function t(t){t.MathJax===undefined?e(t.document):t.MathJax.Hub.Queue(new t.Array('Typeset',t.MathJax.Hub))}var n=document.getElementsByTagName('iframe'),r,i;t(window);for(r=0;r<n.length;r++)i=n[r].contentWindow||n[r].contentDocument,i.document||(i=i.parentN
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@baiyanhuang
baiyanhuang / programsegment.cpp
Created December 8, 2012 12:40
Display address of program segments
#include <iostream>
using namespace std;
// .data - read-write data
int rwdata = 100;
// .rodata - read-only data
const char* rodata = "hello, world";
@qiukun
qiukun / gist:3000173
Created June 26, 2012 23:37
send mail to tumblr by coffeescript and nodemailer
nodemailer = require "nodemailer"
smtpTransport = nodemailer.createTransport "SMTP",
service: "Gmail"
auth:
user:
pass:
mail =
from: ""
@RaVbaker
RaVbaker / gist:2967695
Created June 21, 2012 18:44
[HOWTO] Ubuntu 12.04 Ruby on Rails Development Environment

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

Step 1: Get the repos ready and run updates.

sudo apt-get update && sudo apt-get upgrade