From | To | Expression |
---|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Compute solutions to the diophantine Pell equation x^2-D*y^2=1.""" | |
import itertools | |
def pell (D): | |
"""Return the smallest integer set solving Pell equation | |
x^2-D*y^2=1 where x, D and y are positive integers. If there are no | |
solution (D is a square), return None. | |
>>> pell(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import ctypes | |
pyint_p = ctypes.POINTER(ctypes.c_byte*sys.getsizeof(5)) | |
five = ctypes.cast(id(5), pyint_p) | |
print(2 + 2 == 5) # False | |
five.contents[five.contents[:].index(5)] = 4 | |
print(2 + 2 == 5) # True (must be sufficiently large values of 2 there...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is going to be on Hackage soon! https://github.com/gatlin/surely | |
{-# LANGUAGE BangPatterns #-} | |
-- | | |
-- Module : AI.Surely | |
-- Copyright : 2012 Gatlin Johnson | |
-- License : LGPL 3.0 | |
-- Maintainer : [email protected] | |
-- Stability : experimental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Inspired by: | |
http://eli.thegreenplace.net/2009/08/29/co-routines-as-an-alternative-to-state-machines/ | |
""" | |
def parse_args(target): | |
"""A generator that parses a stream of arguments one character at a time. | |
As soon as a flag, or flag value pair ("-a" or "-a value") is processed | |
the pair is sent off as a tuple to the 'target' generator. |
Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU
Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys
Consumer key: CjulERsDeqhhjSme66ECg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Installing Arch: | |
sudo vim /etc/pacman.conf | |
Update packages list: sudo pacman -Syy | |
run sudo pacman -Syu before installing any software (to update the repositories first) | |
* Timing issue: | |
- Change hardware clock to use UTC time: | |
sudo timedatectl set-local-rtc 0 |
This pass has the job of enforcing memory safety. This is a subtle topic. This docs aim to explain both the practice and the theory behind the borrow checker. They start with a high-level overview of how it works, and then proceed to dive into the theoretical background. Finally, they go into detail on some of the more subtle aspects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.State.Lazy | |
import Control.Monad.Error | |
import Control.Monad.Identity | |
import Control.Applicative | |
import Data.Char | |
-- Begin parser | |
type Parser a = StateT String (ErrorT String Identity) a |
OlderNewer