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
package main | |
import ( | |
`bytes` | |
`fmt` | |
`net/url` | |
`encoding/json` | |
) | |
type Ex struct { |
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
function checkPalindrome(str) { | |
return str == str.split('').reverse().join(''); | |
} | |
function gen_key(a, b) { | |
if (a <= b) { | |
return a + '*' + b; | |
} | |
return b + '*' + a; | |
} |
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 io | |
import logging | |
logging.getLogger('googleapiclient.discovery').setLevel(logging.WARNING) | |
logging.getLogger('oauth2client.client').setLevel(logging.WARNING) | |
from apiclient.discovery import build | |
from apiclient.http import ( | |
MediaIoBaseDownload, | |
MediaFileUpload, | |
) |
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 | |
from time import sleep | |
from lockfile.pidlockfile import PIDLockFile | |
if __name__ == '__main__': | |
# If we can't acquire a lock in 1 second, raise an exception. | |
with PIDLockFile('/home/me/script.pid', timeout=1): | |
while True: | |
sys.stdout.write('Check /home/me/script.pid for my process id\n') |
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
mkdir bash-fix | |
cd bash-fix | |
curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf - | |
cd bash-92/bash-3.2 | |
curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-052 | patch -p0 | |
cd .. | |
xcodebuild | |
sudo cp /bin/bash /bin/bash.old | |
sudo cp /bin/sh /bin/sh.old | |
build/Release/bash --version # GNU bash, version 3.2.52(1)-release |
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
/** | |
Here's an example of failing to return the correct type | |
*/ | |
object CovarianceExampleFailFirst { | |
/** | |
Covariance example (does not compile) | |
def mixFoods[T >: Watermelon](food: T): List[T] = { |
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
/** | |
Here is an object that has a method mixFoods which will accept | |
a subclass of a GardenItem and return a list of either | |
GardenItems or subclasses of GardenItems. | |
*/ | |
object CovarianceExample { | |
/** | |
Covariance example (compiles) |
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
class Dirt | |
class GardenItem extends Dirt { | |
val flavor = "seedy" | |
} | |
class Cucumber extends GardenItem { | |
override val flavor = "bland" | |
} |
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
/** Base class, since all things from the produce department come from a garden. */ | |
class GardenItem { | |
val flavor = "seedy" | |
} |
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
;; Show long running queries. | |
SELECT pid, state, query_start, query FROM pg_stat_activity; | |
;; Kill a long running query. | |
SELECT pg_cancel_backend(<pid of the query from previous query>); |
NewerOlder