Skip to content

Instantly share code, notes, and snippets.

@Ilgrim
Ilgrim / sha256_file.py
Created August 22, 2017 16:01 — forked from eas604/sha256_file.py
sha256 file checksum function in python
def sha256_file(file_path, chunk_size=65336):
"""
Get the sha 256 checksum of a file.
:param file_path: path to file
:type file_path: unicode or str
:param chunk_size: number of bytes to read in each iteration. Must be > 0.
:type chunk_size: int
:return: sha 256 checksum of file
:rtype : str
"""
@Ilgrim
Ilgrim / dirwalk.py
Created August 22, 2017 16:42 — forked from gkalab-snippets/dirwalk.py
Python: dirwalk
import os
def dirwalk(directory):
"walk a directory tree, using a generator"
for name in os.listdir(directory):
fullpath = os.path.join(directory, name)
if os.path.isdir(fullpath) and not os.path.islink(fullpath):
for name in dirwalk(fullpath): # recurse into subdir
yield name
@Ilgrim
Ilgrim / gist:43702323d830c0222be37ae023fc0b18
Created August 24, 2017 23:44 — forked from evertrol/gist:47325e62f8caae1b72ee
Asyncio: cancel a set of coroutines from another coroutine, by stopping the event loop
"""Example to cancel a set of asyncio coroutines (futures),
using one coroutine to signal the event loop to stop.
"""
import asyncio
import logging
from datetime import datetime
from concurrent.futures import CancelledError
@Ilgrim
Ilgrim / PdfParser.php
Created October 21, 2017 10:11 — forked from smalot/PdfParser.php
Use this static class to extract Text from Pdf files. It supports compressed and uncompressed Pdf (version 1.1 to 1.7) : tested It supports octal encoded (eg : \050) content, but not hexadecimal (eg : <005E>). In some cases, it works better than "pdftotext" binary tool.
<?php
/**
* @file
* Class PdfParser
*
* @author : Sebastien MALOT <sebastien@malot.fr>
* @date : 2013-08-08
*
* References :
@Ilgrim
Ilgrim / irc.php
Created October 24, 2017 07:16 — forked from xeoncross/irc.php
Test IRC client bot in PHP
<?php
$server = 'ssl://example.com';
$port = 12345;
$pass = 'pass';
$nick = 'user';
$channel = '#channel';
function send( $conn, $msg )
{
@Ilgrim
Ilgrim / PostMessageToSlackChannel.php
Created October 24, 2017 07:18 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar
@Ilgrim
Ilgrim / webrtc.js
Created November 30, 2017 16:14 — forked from dristic/webrtc.js
Full code from my WebRTC Data Channel post.
// Fix Vendor Prefixes
var IS_CHROME = !!window.webkitRTCPeerConnection,
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription;
if (IS_CHROME) {
RTCPeerConnection = webkitRTCPeerConnection;
RTCIceCandidate = window.RTCIceCandidate;
RTCSessionDescription = window.RTCSessionDescription;
@Ilgrim
Ilgrim / cs.py
Last active January 1, 2018 22:22 — forked from myano/cs.py
Quick example of ncurses in Python!
#!/usr/bin/env python
import curses
import curses.textpad
import time
stdscr = curses.initscr()
#curses.noecho()
#curses.echo()
@Ilgrim
Ilgrim / bash-colors.md
Created January 1, 2018 22:40 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@Ilgrim
Ilgrim / posts_from_page.php
Created January 4, 2018 18:39 — forked from morales2k/posts_from_page.php
Get Facebook public posts from a page. This requires facebook's php sdk, and a properly registered app.
<?php
function make_links($text, $class='', $target='_blank'){
return preg_replace('!((http\:\/\/|ftp\:\/\/|https\:\/\/)|www\.)([-a-zA-Zа-яА-Я0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?!ism', '<a class="'.$class.'" href="//$3" target="'.$target.'">$1$3</a>', $text);
}
define("APP_ID", 'xxxxxxxxxxxxxxxxxxx');
define("APP_SECRET",'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define("PAGE_ID",'elnuevodia');
$config = array(
'appId' => APP_ID,