Skip to content

Instantly share code, notes, and snippets.

View fredtux's full-sized avatar
📚
Studying for uni

Florin Dinu fredtux

📚
Studying for uni
View GitHub Profile
@fredtux
fredtux / ddnsserver.py
Created March 17, 2023 16:02 — forked from pklaus/ddnsserver.py
Simple DNS server (UDP and TCP) in Python using dnslib.py
#!/usr/bin/env python
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import argparse
import datetime
import sys
import time
import threading
@fredtux
fredtux / 0.hs
Created November 13, 2022 02:46
Haskell memorization card
-- String to Int with ord
toNum :: [Char] -> Int
toNum [] = 0
toNum x = (let (z:xs) = x in (ord z) - (ord '0')) * 10 ^ (length x - 1) + let (z:xs) = x in toNum xs
-- Trimodal logic
data Trimodal = Yes | No | Unknown deriving (Show)
(&&&) :: Trimodal -> Trimodal -> Trimodal
Yes &&& Yes = Yes
import feedparser
import time
import re
import smtplib
from datetime import datetime
import urllib2
def internet_on():
try:
urllib2.urlopen('http://216.58.192.142', timeout=1)
@fredtux
fredtux / IntelliJGnome3.py
Created November 18, 2018 19:59
Creates IntelliJ launchers for Gnome 3
############################################################
########## Creates IntelliJ launchers for GNOME 3 ##########
############################################################
import os
import pwd
import os.path
class Gnome3Application():
def __init__(self, name, comment, categories, version):
@fredtux
fredtux / JS_FredTux.xml
Last active January 15, 2019 14:29
PhpStorm templates
<templateSet group="JS_FredTux">
<template name="jcl" value="console.log($1$);" description="console.log" toReformat="false" toShortenFQNames="true">
<variable name="1" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_SCRIPT" value="true" />
</context>
</template>
<template name="jcll" value="&#10;console.log($1$);" description="new line + console.log" toReformat="false" toShortenFQNames="true">
<variable name="1" expression="" defaultValue="" alwaysStopAt="true" />
<context>
@fredtux
fredtux / Regex.cs
Last active June 23, 2017 09:52
Regex CLR
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text.RegularExpressions;
public partial class UserDefinedFunctions {
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlBoolean RegexMatch(string inputValue, string regexPattern) {
@fredtux
fredtux / 1.sp_BAKFolders.sql
Last active June 23, 2017 09:54
Restore the most recent SQL Server database backup from each subdirectory
-------------------------------------------------------------
----- Returns file list of dynamically specified .bak -----
-------------------------------------------------------------
CREATE PROC sp_dynRestoreFileList
( @pPath nvarchar(255) )
AS
RESTORE FILELISTONLY
FROM DISK=@pPath
GO