Skip to content

Instantly share code, notes, and snippets.

View ddmitov's full-sized avatar

Dimitar D. Mitov ddmitov

View GitHub Profile
@rkulla
rkulla / quickscan.pl
Last active December 29, 2022 05:39
Simple Perl-based Port Scanner
#!/usr/bin/perl
# Easy port scanner
# I wrote this in the 90s to help learn socket programming
# ./quickscan -h for usage
use Socket;
$| = 1; # so \r works right
my ($ip, $protocol, $port, $myhouse, $yourhouse, $log);
@diegok
diegok / test.pl
Created January 4, 2012 19:50
Example mojo lite app sending plain json
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render( text => '{"json":"ok"}', status => 201, format => 'json');
};
app->start;
@gjorquera
gjorquera / console.cpp
Last active July 22, 2024 09:45
Qt way to read from stdin.
#include <iostream>
#include "console.hpp"
void Console::run()
{
std::cout << "First message" << std::endl;
std::cout << "> " << std::flush;
connect(m_notifier, SIGNAL(activated(int)), this, SLOT(readCommand()));
}
@leommoore
leommoore / node_child_processes.markdown
Last active May 30, 2023 08:22
Node - Child Processes

#Node - Processes To launch an external shell command or executable file you can use the child_process. Apart from command line arguments and environment variables you cannot communicate with the process using child_process.exec. However you can use child_process.spawn to create a more integrated processes.

##Executing Child Processes

###To launch an external shell command

var child_process = require('child_process');
var exec = child_process.exec;
@nabucosound
nabucosound / vim_cheatsheet.rst
Last active March 4, 2021 08:42
Vim basic commands cheatsheet. Nothing advanced here, just basic stuff to help my lazy mind remember.

Nabuco's Vim cheatsheet

Normal mode (a.k.a command mode)

i -> insert left of cursor
@manics
manics / check_utf8.py
Created February 4, 2013 15:17
Check whether a file contains valid UTF-8. Returns 0 for valid UTF-8, prints an error message to STDOUT and returns 1 for invalid.
#!/usr/bin/env python
# Check whether a file contains valid UTF-8
# From http://stackoverflow.com/a/3269323
import codecs
import sys
import os
def checkFile(filename):
try:
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@jnormore
jnormore / bootstrap3-alert-box.js
Last active November 10, 2019 13:07
Bootstrap 3 alert and confirm modals. Overrides window.alert normally, but window.confirm override requires a callback function to be passed to get result. Optional arguments for modal title and confirm button label.
window.alert = function(message, title) {
if($("#bootstrap-alert-box-modal").length == 0) {
$("body").append('<div id="bootstrap-alert-box-modal" class="modal fade">\
<div class="modal-dialog">\
<div class="modal-content">\
<div class="modal-header" style="min-height:40px;">\
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>\
<h4 class="modal-title"></h4>\
</div>\
<div class="modal-body"><p></p></div>\
@dex4er
dex4er / mojo-app.pl
Last active February 12, 2019 11:53
Mojolicious + PAR::Packer without --addfile
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
use Mojolicious::Lite;
# Explicit use as a helper for PAR
@srv89
srv89 / python_email.py
Last active January 29, 2024 00:24
Python code for sending HTML email (Attachment + Multiple Recipients )
__author__ = 'srv'
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
username = '' # Email Address from the email you want to send an email
password = '' # Password
server = smtplib.SMTP('')