Skip to content

Instantly share code, notes, and snippets.

View idoshamun's full-sized avatar

Ido Shamun idoshamun

View GitHub Profile
@thomasvamos
thomasvamos / plot_confusion_matrix.py
Created October 19, 2013 11:31
Python code snippet to plot a greyscale confusion matrix. Its tailored to a project I did, but you get the idea.
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import random
def main():
true_labels = [random.randint(1, 10) for i in range(100)]
predicted_labels = [random.randint(1, 10) for i in range(100)]
plot = getConfusionMatrixPlot(true_labels, predicted_labels)
plot.show()
@Scarygami
Scarygami / with-debounce
Last active December 8, 2017 20:03
Polymer debounce sample
Polymer({
is: 'with-debounce',
properties: {
property1: {
type: String,
observer: '_doSomething'
},
property2: {
type: String,
observer: '_doSomething'
@jaynzr
jaynzr / cloudsql_proxy.service
Last active February 5, 2018 08:10
CloudSQL Proxy systemd /etc/systemd/system/cloudsql_proxy.service /etc/systemd/system/cloudsql_proxy.service.d/settings.conf
[Unit]
Description=CloudSQL Proxy
After=network.target
[Service]
User=nobody
Group=nobody
WorkingDirectory=/usr/local/bin
ExecStart=/usr/local/bin/cloud_sql_proxy -dir=/cloudsql -instances=${INSTANCES}
@Mando75
Mando75 / PaginationHelper.ts
Last active March 7, 2020 23:44
An example PaginationHelper for typeorm graphql loader
import { FieldNode, GraphQLResolveInfo, SelectionNode } from "graphql";
import { GraphQLDatabaseLoader } from "@mando75/typeorm-graphql-loader";
import { SearchOptions, FeedNodeInfo } from "@mando75/typeorm-graphql-loader/dist/types";
import { LoaderSearchMethod } from "@mando75/typeorm-graphql-loader/dist/base";
import { OrderByCondition } from "typeorm";
type getFeedOptions = {
search?: SearchOptions;
order?: OrderByCondition;
};
@ebidel
ebidel / polymer-perf-bookmarklet.js
Last active May 1, 2021 15:42
Polymer performance numbers bookmarklet
javascript:(function(){(function printStats(){var loadTimes=window.chrome.loadTimes();firstPaint=loadTimes.firstPaintTime*1000;firstPaintTime=firstPaint-(loadTimes.startLoadTime*1000);console.info('First paint took',firstPaintTime,'ms');console.info('Load took',performance.timing.loadEventStart-performance.timing.navigationStart,'ms');var instances=0;if(parseFloat(Polymer.version)<1){instances=[].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}).length;}else{instances=Polymer.telemetry.instanceCount;}console.info('Custom element instances:',instances);var reflectCount=0;if(Polymer.telemetry){console.info('=== Properties set to reflectToAttribute ===');Polymer.telemetry.registrations.forEach(function(el){for(var prop in el.properties){if(el.properties[prop].reflectToAttribute){console.log(el.is+'.'+prop);reflectCount++;}}});}else{console.info('=== Properties set to reflect ===');Polymer.elements.forEach(function(el){for(var
@Couto
Couto / package.json
Last active February 13, 2022 22:16
Test case for file uploads with Hapi.js. Currently failing when same request is made with a simple JSON.
{
"name": "file-upload",
"version": "1.0.0",
"description": "File Upload test case",
"main": "server.js",
"dependencies": {
"hapi": "^8.0.0-rc8",
"joi": "^5.0.2"
},
"devDependencies": {
@whizzzkid
whizzzkid / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Last active December 3, 2022 15:43
[XPS 15 Early 2017 9560 kabylake] Making Nvidia Drivers + (CUDA 8 / CUDA 9 / CUDA 9.1) + Bumblebee work together on linux ( Ubuntu / KDE Neon / Linux Mint / debian )
# Instructions for 4.14 and cuda 9.1
# If upgrading from 4.13 and cuda 9.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-9.0/
# Important libs required with 4.14.x with Cuda 9.X
$ sudo apt install libelf1 libelf-dev
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
!function() {
var doc = document,
htm = doc.documentElement,
lct = null, // last click target
nearest = function(elm, tag) {
while (elm && elm.nodeName != tag) {
elm = elm.parentNode;
}
return elm;
};