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
function getPathTo(element) { | |
if (element.id!=='') | |
return 'id("'+element.id+'")'; | |
if (element===document.body) | |
return element.tagName; | |
var ix= 0; | |
var siblings= element.parentNode.childNodes; | |
for (var i= 0; i<siblings.length; i++) { | |
var sibling= siblings[i]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 numpy import exp, array, random, dot | |
training_set_inputs = array([[0, 0, 1], [1, 1, 1], [1, 0, 1], [0, 1, 1]]) | |
training_set_outputs = array([[0, 1, 1, 0]]).T | |
random.seed(1) | |
synaptic_weights = 2 * random.random((3, 1)) - 1 | |
for iteration in xrange(10000): | |
output = 1 / (1 + exp(-(dot(training_set_inputs, synaptic_weights)))) | |
synaptic_weights += dot(training_set_inputs.T, (training_set_outputs - output) * output * (1 - output)) | |
print 1 / (1 + exp(-(dot(array([1, 0, 0]), synaptic_weights)))) |
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
# Rename files from .HTM --> .html | |
#!/bin/bash | |
for file in *.HTM; do | |
name=$(basename "$file" .HTM) | |
mv "$file" "$name.html" | |
done | |
----------------------------------------------------------------- |
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 re | |
def show_time_of_pid(line): | |
pattern = r'^(\w+ [0-9] [0-9]+:[0-9]+:[0-9]+) [\w\.]+ [\w=]+\[([0-9]+)\]' | |
result = re.search(pattern, line) | |
return '{} pid:{}'.format(result[1],result[2]) | |
print(show_time_of_pid("Jul 6 14:01:23 computer.name CRON[29440]: USER (good_user)")) # Jul 6 14:01:23 pid:29440 | |
print(show_time_of_pid("Jul 6 14:02:08 computer.name jam_tag=psim[29187]: (UUID:006)")) # Jul 6 14:02:08 pid:29187 |
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 os | |
def parent_directory(): | |
# Create a relative path to the parent | |
# of the current working directory | |
relative_parent = os.path.join(os.getcwd(), os.pardir) | |
# Return the absolute path of the parent directory | |
return os.path.abspath(relative_parent) | |
print(parent_directory()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 merge_lists(left_sublist,right_sublist): | |
i,j = 0,0 | |
result = [] | |
#iterate through both left and right sublist | |
while i<len(left_sublist) and j<len(right_sublist): | |
#if left value is lower than right then append it to the result | |
if left_sublist[i] <= right_sublist[j]: | |
result.append(left_sublist[i]) | |
i += 1 | |
else: |
NewerOlder