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
try (var distLock = distributedLockProvider.lock("some-key", 3000, 10000)) { | |
if (distLock.isEmpty()) | |
return; | |
log.info("I'm running..."); | |
} catch (Exception e) { | |
} |
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
@Configuration | |
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | |
public class ShedlockMongoConfiguration { | |
private final MongoFactory mongoFactory; | |
private final MongoReplicaSetFactory mongoReplicaSetFactory; | |
@Value("${sahibinden.mongodb.dbs.sahibinden.replicaSetName}") | |
private String mongoReplicaSetName; |
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
public interface DistributedLockProvider { | |
DistLock lock(String key, int lockAtLeastFor, int lockAtMostFor); | |
} |
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
@Service | |
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | |
@Slf4j | |
public class DistributedLockProviderImpl implements DistributedLockProvider { | |
private final LockProvider lockProvider; | |
@Override | |
public DistLock lock(String key, int lockAtLeastFor, int lockAtMostFor) { | |
var lockConfiguration = new LockConfiguration(Instant.now(), key, |
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 egcodes; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
/** | |
* @author egcodes | |
*/ |
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 array | |
class ReadFileUsingBit: | |
def __init__(self): | |
fileName = "file.txt" | |
buffer = "" | |
for b in self.readBitByBit(open(fileName, 'r')): | |
buffer += str(b) |
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 urllib2 | |
for a in range(1, 256): | |
for b in range(1, 256): | |
for c in range(1, 256): | |
for d in range(1, 256): | |
ip = "%d.%d.%d.%d"%(a,b,c,d) | |
buf = "" | |
print ip |
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 os, time | |
import pyscreenshot as ImageGrab | |
while True: | |
screen = ImageGrab.grab() | |
dark = 0 | |
bright = 0 | |
for i in screen.getdata(): | |
if i[0] > 150 and i[1] > 150 and i[2] > 150: |
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
from BeautifulSoup import BeautifulSoup | |
import urllib2 | |
from datetime import datetime | |
import time,os | |
pageNo = 1 | |
while pageNo < 10: | |
print "PageNo: %d"%pageNo | |
page = urllib2.urlopen("http://www.zone-h.org/archive/page=%d"%pageNo, timeout=10).read() | |
soup = BeautifulSoup(page) |
NewerOlder