This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from scipy.sparse import csr_matrix | |
A = numpy.array([[0, 0, 1],[0,2,4]]) | |
# array([[0, 0, 1], | |
# [0, 2, 4]]) | |
B = csr_matrix(A) | |
d = B.getnnz(axis=1) # Get number of non zero entries | |
print(d) | |
# array([1, 2], dtype=int32) | |
print(B.sum(axis=1).A.reshape(-1)/d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OptimizationJob(models.Model): | |
def generate_primary_key(): | |
no = randint(13537086546263552, 839299365868340223) | |
str_no = Base62.encode(no) | |
result_count = OptimizationJob.objects.filter(job_id=str_no).count() | |
while result_count > 0: | |
no = randint(13537086546263552, 839299365868340223) | |
str_no = Base62.encode(no) | |
result_count = OptimizationJob.objects.filter(job_id=str_no).count() | |
return str_no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stop all containers | |
docker-compose stop | |
# Remove all containers | |
docker rm -v $(docker ps -a -q) | |
# Remove all images | |
docker rmi $(docker images -q) | |
# Remove all volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import optimize | |
def objective_function(x): | |
return x[0] + x[1] | |
def constraint1(x): | |
# x + y == 12 | |
return x[0] + x[1] - 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_column_letter(column_no): | |
""" | |
A = 0 | |
Z = 25 | |
AA = 26 | |
AB = 27 | |
BA = 52 | |
:param column_no: The 0-based column index. | |
:return: The column as a combination of letters. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace MultiThreadTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BeaconDetector.h | |
// WMWallet | |
// | |
// Created by Friedrich Ewald on 18.02.16. | |
// Copyright © 2016 fewald. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@import CoreLocation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file combiner | |
# combines csv files into one | |
import os | |
for f in os.listdir('export'): | |
print 'Processing file %s' % f | |
with open('export/' + f, 'r') as h: | |
filename = str() | |
if f.endswith('electricityrates.csv'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file formatter for csv files | |
import os | |
ctr = 6 | |
cctr = 0 | |
for f in os.listdir('to import'): | |
print 'Processing file %s' % f | |
with open('to import/' + f, 'r') as h: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT OVERWRITE LOCAL DIRECTORY '${hiveconf:output_file}' | |
ROW FORMAT DELIMITED | |
FIELDS TERMINATED BY ',' | |
SELECT hashtag.object, COUNT(*) as amount | |
FROM | |
${hiveconf:table} t1 | |
JOIN | |
${hiveconf:table} t2 | |
ON |
NewerOlder