This file contains hidden or 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
func encryptKYCData(plainText string) string { | |
// refer this - https://chat.openai.com/share/1f7f6ca1-23fb-45c3-9fb1-88c42efb9880 | |
password := []byte(os.Getenv("ENCRYPTION_KEY")) | |
// pad the plaintext if it is not a muliple of aes.BlockSize | |
plainTextBytes := []byte(plainText) | |
padLength := aes.BlockSize - len(plainTextBytes)%aes.BlockSize | |
padding := bytes.Repeat([]byte{byte(padLength)}, padLength) | |
plainTextBytes = append(plainTextBytes, padding...) | |
cipherText := make([]byte, len(plainTextBytes)) |
This file contains hidden or 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 matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
import time | |
fig = plt.figure() | |
ax1 = fig.add_subplot(1,1,1) | |
def animate(i): | |
# Donald Trump's tweet results were in twitter-out.txt | |
# Hillary Clinton's tweet results were in twitter-out1.txt |
This file contains hidden or 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 nltk | |
import pickle | |
from nltk.classify.scikitlearn import SklearnClassifier | |
def pickling(file, document_name): | |
save_documemts = open('../pickled_algos/' + document_name + '.pickle', 'wb') | |
pickle.dump(file, save_documemts) | |
save_documemts.close() | |
# let the training_set contains data in the form of - |
This file contains hidden or 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 tweepy import Stream | |
from tweepy import OAuthHandler | |
from tweepy import api | |
from tweepy.streaming import StreamListener | |
import json | |
#consumer key, consumer secret, access token, access secret. | |
ckey="<ckey>" | |
csecret="<csecret>" | |
atoken="<atoken>" |
This file contains hidden or 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
/** | |
* @Post("/magic_link_signup") | |
*/ | |
function magicLinkSignUp($request) { | |
// get the query parameters from the post request | |
$queryParams = $request->query()->all(); | |
// get the token from queryParams | |
// this $token is the same $randomString that was | |
// generated in Step 1 |
This file contains hidden or 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
/** | |
* pass mobile number of the user for whom | |
* you want to create an authenticated link, | |
* this mobile number may/may not be in your | |
* user's database | |
*/ | |
function createMagicLink($mobileNumber, $targetScreenUrl) { | |
// generate a random string of length 8 | |
$randomString = generateRandomString(8); | |
$maskedRandomString = generateMaskedRandomString($randomString); |
This file contains hidden or 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
if ($this->lockHandlerUtil->isDuplicateInstanceRunning()) { | |
// trigger some kind of alert | |
return; | |
} | |
/* | |
actual cron code | |
.... | |
.... | |
*/ |
This file contains hidden or 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->lockHandlerUtil = new LockHandlerUtil( | |
$this->getName(), | |
$this->getContainer()->get('kernel')->getRootDir() | |
); | |
// $this->getName() will return the current file name | |
// of the Command (Cron) in Symfony framework. |
This file contains hidden or 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 LockHandlerUtil | |
*/ | |
class LockHandlerUtil | |
{ | |
/** | |
* @param String $fileName | |
* @param String $rootDir | |
*/ | |
public function __construct($fileName, $rootDir) |
This file contains hidden or 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
/** | |
* @param Integer $pid | |
* | |
* @return boolean | |
*/ | |
public function isProcessRunning($pid) | |
{ | |
if (file_exists("/proc/".$pid)) { | |
return true; | |
} |
NewerOlder