Skip to content

Instantly share code, notes, and snippets.

@sveinn-steinarsson
sveinn-steinarsson / solver.py
Last active June 10, 2023 20:45
Solver for the puzzle game 4=10
"""
This simple 4=10 game solver is intended for educational purposes only.
"""
import sys
from itertools import product, permutations
WELCOME = """Solver for the puzzle game 4=10
Get the game app: https://fourequalsten.app/
Insert a four digit number.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Sample solution for the puzzle in the job advertisement from Já Gallup
Cipher: ahsr pz jolhw. zovd tl aol jvkl − spubz avychskz
Hint: j->c
"""
print(''.join([(chr((ord(c) - (97 + ord('j') - ord('c'))) % 26 + 97) if c.isalpha() else c) for c in 'ahsr pz jolhw. zovd tl aol jvkl − spubz avychskz']))
@sveinn-steinarsson
sveinn-steinarsson / get_pipeline_urls.py
Created July 14, 2014 12:51
Use django pipeline in Class Media (for example in admin.py)
from django.contrib.staticfiles.storage import staticfiles_storage
from pipeline.packager import Packager
from pipeline.conf import settings
def get_pipeline_urls(package_type, package_name):
packager = Packager()
package = packager.package_for(package_type, package_name)
if settings.PIPELINE_ENABLED:
return ( staticfiles_storage.url(package.output_filename), )
@sveinn-steinarsson
sveinn-steinarsson / powerssh.ps1
Last active November 5, 2021 16:35
Use Powershell to connect to a remote server via SSH and run a shell script/command
# Script Name: powerssh
# Version: 1.1.0 (9. July, 2014)
# Author: Sveinn Steinarsson
# Description: Use Powershell to connect to a remote server via SSH and run a shell script/command
# Prerequisite:
# plink.exe in script path (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
# Examples:
# With key file (*.ppk) and script file
@sveinn-steinarsson
sveinn-steinarsson / DumpNoData.ps1
Last active August 29, 2015 13:59
Dump common user defined MSSQL database objects (including table structures, procedures, views, etc.) into SQL script files and place into folders. Useful when working with source control tools like GIT.
# Script Name: DumpNoData
# Version: 1.0.1 (2. June, 2014)
# Author: Sveinn Steinarsson
<#
.SYNOPSIS
Dumps the structure of a MSSQL database into SQL scripts files, including tables, procedures, triggers, etc.
.DESCRIPTION
Common user defined database objects are dumped into SQL script files and placed into folders.
The main purpose is to be used with version control tools such as GIT.