Skip to content

Instantly share code, notes, and snippets.

翁治平 gocreating

  • Taiwan
View GitHub Profile
View app.js
var router = express.Router();
require('./routes/main/user')(router);
View user.js
var User = require('../../models/user');
module.exports = function (router) {
router.route('/api/user')
.get(function (req, res) {
console.log('get');
User.readAll(function (err, readUsers) {
// reply is a custom function added by my middleware
res.reply(readUsers, err, 'cannot read users');
});
View angular
// service.js
app
.factory('authService', ['$http', function ($http) {
var auth = {
isAuth: false,
user: null
};
$http
.get('/api/session')
View angular
// service.js
.factory('authService', ['$http', '$route', function ($http, $route) {
var auth = {
isAuth: false,
user: null
};
$http
.get('/api/session')
.success(function (data) {
View models.py
from django.db import models
class Field(models.Model):
device_id = models.IntegerField()
field = models.IntegerField()
class Sensor(models.Model):
name = models.CharField(max_length=30)
device_id = models.IntegerField()
fields = models.ForeignKey(Field)
View zz
module multiplier(load, clk, m1, m2, ready, P);
input [7:0] m1, m2;
input load, clk;
output [15:0] P;
output ready;
reg [7:0] A, B;
reg [15:0] pp, P;
View gist:cf8197d33e4fa1f641d9
#! /usr/bin/env node
var globalInstanceId;
var qs = require('querystring');
var http = require("http");
var server = http.createServer(function (request, response) {
console.log(request.url, request.remoteAddress);
if (request.method == 'POST') {
var body = '';
View Yahoo Weather API Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Yahoo Weather API</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<select id="cities"></select>
View 網路通訊原理hw3-2
var f = function(n) {
if (n <= 1) {
return 1;
} else {
return n * f(n - 1);
}
}
var getP0 = function(y) {
var sum = 0;
View flux problem
// flux.js
var Alt = require('alt');
export default class Flux extends Alt {
constructor() {
super();
this.addActions('ActionCreators', require('./actions/TodoActions'));
this.addStore('TodoStore', require('./stores/TodoStore'));
You can’t perform that action at this time.