Skip to content

Instantly share code, notes, and snippets.

View TheOnlyWayUp's full-sized avatar
📰
Democratizing information

Dhanush R TheOnlyWayUp

📰
Democratizing information
View GitHub Profile
#! /usr/bin/env python3
import select
import socket
import time
TIME_WAIT = 0.01
BIND_ADDR = ''
BIND_PORT = 8443
SERV_ADDR = 'server.example.com'
@zhangsen
zhangsen / relative_time.py
Created September 7, 2011 07:22
python-relative-time
#
# This piece of code is in the public domain.
# <zh.jesse@gmail.com>
#
from datetime import datetime
def get_age(date):
'''Take a datetime and return its "age" as a string.
The age can be in second, minute, hour, day, month or year. Only the
@lancejpollard
lancejpollard / meta-tags.md
Created March 5, 2012 13:54
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@Jxck
Jxck / server.js
Created July 24, 2012 17:09
WebSocket Server Sample Impliment
// Reference
// http://tools.ietf.org/html/rfc6455
// http://www.w3.org/TR/2011/WD-websockets-20110929/
// https://github.com/einaros/ws
// https://github.com/Worlize/WebSocket-Node
// http://ja.wikipedia.org/wiki/WebSocket
// http://www.slideshare.net/You_Kinjoh/javascript-websocket P.68
// http://d.hatena.ne.jp/gtk2k/20120203/1328274962
var log = console.log.bind(console);
@eaorak
eaorak / hangman.py
Created October 31, 2012 09:59
Python - Hangman Game
#!/usr/bin/python3
# Hangman game
import random
class HangMan(object):
# Hangman game
hang = []
hang.append(' +---+')
@vunb
vunb / ffmpeg-convert-mp3-to-wave
Created November 7, 2013 04:52
Convert mp3 to wave format using ffmpeg
ffmpeg -i input.mp3 -acodec pcm_s16le -ac 1 -ar 16000 output.wav
# To convert all mp3 files in a directory in Linux:
for f in *.mp3; do ffmpeg -i "$f" -acodec pcm_s16le -ac 1 -ar 16000 "${f%.mp3}.wav"; done
# Or Windows:
for /r %i in (*) do ffmpeg -i %i -acodec pcm_s16le -ac 1 -ar 16000 %i.wav
@yyx990803
yyx990803 / starcounter.js
Last active March 24, 2024 05:25
Count your total stars!
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
console.log(res.message)
return
}
var pages = Math.ceil(res.public_repos / 100),
@yurydelendik
yurydelendik / gist:f2b846dae7cb29c86d23
Last active April 26, 2024 20:39
PDF.js get/show hightlight
function getHightlightCoords() {
var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var selected = selectionRects.map(function (r) {
return viewport.convertToPdfPoint(r.left - pageRect.x, r.top - pageRect.y).concat(
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
});
from wpf import *
# Create window
my_window = Window()
my_window.Title = 'Welcome to IronPython'
# Create StackPanel to Layout UI elements
my_stack = StackPanel()
my_stack.Margin = Thickness(15)
my_window.Content = my_stack
@lukas-h
lukas-h / license-badges.md
Last active May 1, 2024 10:20
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)