Skip to content

Instantly share code, notes, and snippets.

View nuqz's full-sized avatar
🗜️
Quitting from IT to manufacturing

Nikolay Koshenkov nuqz

🗜️
Quitting from IT to manufacturing
View GitHub Profile
from keras.callbacks import Callback
class PatientTrainingCallback(Callback):
def __init__(self):
Callback.__init__(self)
self.episode_finished = True
self.end_train_before_episode_end = False
def on_train_begin(self, logs=None):
pass
import io
import json
from socket import socket, AF_INET, SOCK_STREAM
class SocketIO(io.RawIOBase):
def __init__(self, sock):
self.sock = sock
def read(self, sz=-1):
if (sz == -1): sz=0x7FFFFFFF
return self.sock.recv(sz)
@nuqz
nuqz / Application.php
Created July 15, 2017 12:01
Getting dummy application namespace to develop Laravel packages
<?
// Insert this before throw in getNamespace()
foreach ((array) data_get($composer, 'autoload-dev.psr-4') as $namespace => $path) {
foreach ((array) $path as $pathChoice) {
if (realpath(app_path()) == realpath(base_path().'/../'.$pathChoice)) {
return $this->namespace = $namespace;
}
}
}
package even_or_odd
import (
"testing"
"math"
)
type Solution func (int) string
var smartMap = map[int]string{0: "Even", 1: "Odd"}
@nuqz
nuqz / snippets.cson
Created May 28, 2017 20:28
React component Atom snippet
'.source.js.jsx':
'Component':
'prefix': 'rcom'
'body': '''
import React, { Component } from 'react'
import PropTypes from 'prop-types'
${1:import ${2:...} from '${3:package}'
}class ${4:MyComponent} extends Component {
@nuqz
nuqz / keymap.cson
Last active May 28, 2017 20:30
Atom "Sublime Text 3"-like Ctrl+D behavior
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
'ctrl-d': 'find-and-replace:select-next'
@nuqz
nuqz / blackberry.fstab
Last active May 22, 2017 16:20
Mounting Blackberry device connected over Wi-Fi as non-root User
# ...
#
# Mounting Blackberry device
//<host>/media <mountpoint> cifs credentials=/home/<user>/.smbcred,user,gid=<user>,uid=<user_group>,file_mode=0640,dir_mode=0750 0 0
@nuqz
nuqz / render_serialized_json_data.rb
Last active December 8, 2016 22:07
RSpec matcher to test JSON API Controller output provided with ActiveModel Serializer.
# Encountered an error when tested console output:
#
# ActiveModelSerializers::Adapter::JsonApi::PaginationLinks::MissingSerializationContextError: JsonApi::PaginationLinks requires a ActiveModelSerializers::SerializationContext.
# Please pass a ':serialization_context' option or
# override CollectionSerializer#paginated? to return 'false'.
# Usual RSpec matcher definition
RSpec::Matchers.define :render_serialized_json_data do |expected|
match do |actual|
# Prepairing serialized JSON from ActiveRecord(s)