Skip to content

Instantly share code, notes, and snippets.

:octocat:
Rust > C++ > Go > TypeScript > C

Samuel Marks SamuelMarks

:octocat:
Rust > C++ > Go > TypeScript > C
View GitHub Profile
@SamuelMarks
SamuelMarks / pip_install_all.bash
Created Jan 23, 2018
[offscale] Install all dependencies via pip
View pip_install_all.bash
#!/usr/bin/env bash
if [ ! -z DIR ]; then DIR=(off*/); fi
VENV="${VENV:-.offenv}"
REQUIREMENTS="${REQUIREMENTS:-'requirements.txt'}";
if [ ! -d "$VENV/bin" ]; then
echo Cannot find "$VENV/bin"
exit 2;
View example.ts
import 'reflect-metadata';
import { createConnection } from 'typeorm';
@Entity('user_tbl')
export class User {
@PrimaryColumn({ type: 'varchar' })
public username: string;
@Column({ type: 'varchar', nullable: false, select: false })
public password: string;
@SamuelMarks
SamuelMarks / mongo_attempt0.js
Last active Nov 15, 2017
OpenEdX datasets attempts to: SELECT grade, student_id, minutes_taken FROM questions_answered GROUP BY exam
View mongo_attempt0.js
// Now ignore everyone else; mongodump to CSV; `LOAD DATA FROM CSV` in MySQL
db.modulestore.structures.aggregate([
{ $unwind: '$blocks' },
{ $replaceRoot: { newRoot: "$blocks" } },
{ $out: 'modulestore.blocks' }
]);
View arch0.dot
digraph {
bgcolor=transparent;
splines=polyline;
phone0[label="Smartphone 0"];
phone1[label="Smartphone 1"];
phone2[label="Smartphone 2"];
laptop0[label="Laptop 0"];
laptop0[label="Laptop 1"];
laptop0[label="Laptop 2"];
server0[label="Server (DB, API, nginx, static files)", shape=cylinder]
View interceptor-response.ts
@Injectable()
class JWTInterceptor implements HttpInterceptor {
constructor(private router: Router) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).map((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
// do stuff with response if you want
View cifar10.patch
diff --git a/tutorials/image/cifar10/cifar10.py b/tutorials/image/cifar10/cifar10.py
index d99ffb9..4edcf68 100644
--- a/tutorials/image/cifar10/cifar10.py
+++ b/tutorials/image/cifar10/cifar10.py
@@ -90,8 +90,8 @@ def _activation_summary(x):
# Remove 'tower_[0-9]/' from the name in case this is a multi-GPU training
# session. This helps the clarity of presentation on tensorboard.
tensor_name = re.sub('%s_[0-9]*/' % TOWER_NAME, '', x.op.name)
- tf.contrib.deprecated.histogram_summary(tensor_name + '/activations', x)
- tf.contrib.deprecated.scalar_summary(tensor_name + '/sparsity',
View has_latest_node.sh
#!/bin/sh
curl -s https://nodejs.org/dist/latest/ | sed -n 's:.*<a href=\".*\">node-v\(.*\).pkg</a>.*:\1:p'
View gist:ac8440d1678e1084cdda1e0d67090324
tttttt$ ls
CMakeLists.txt conanfile.txt main.cpp
tttttt$ mkdir build && cd $_
tttttt/build$ conan install ..
RapidJSON/1.0.2@SamuelMarks/testing: Not found, looking in remotes...
RapidJSON/1.0.2@SamuelMarks/testing: Trying with 'conan.io'...
Downloading conan_export.tgz
[==================================================]
Downloading conanfile.py
[==================================================]
View httpPOST.js
var http = require('http');
function httpPOST(options, body, cb) {
const req = http.request(options, function (res) {
if (!res)
return cb(res);
else if ((res.statusCode / 100 | 0) > 3)
return cb(res);
return cb(null, res);
View http_post.js
"use strict";
var http_1 = require('http');
function httpF(method) {
return function (options, body_or_cb, cb) {
if (!cb) {
cb = body_or_cb;
body_or_cb = null;
}
options['method'] = method;
if (body_or_cb)
You can’t perform that action at this time.