Skip to content

Instantly share code, notes, and snippets.

@srcecde
srcecde / MainActivity.java
Created January 24, 2017 05:25
Retrieve Filtered Data In Android Using PHP MySQL
package com.app.srcecde.search_example1;
import android.content.ContentValues;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@srcecde
srcecde / port_scanner.py
Last active February 6, 2017 08:19
Demo threaded Port Scanner
import threading
from queue import Queue
import socket
server = 'hackthissite.org'
ip = socket.gethostbyname(server)
def portscan(port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
@srcecde
srcecde / lambda_function.py
Last active July 12, 2022 08:22
AWS: Reading File content from S3 on Lambda Trigger
import boto3
import urllib
def lambda_handler(event, context):
s3 = boto3.client("s3")
if event:
print("Event : ", event)
file_obj = event["Records"][0]
filename = str(file_obj['s3']['object']['key'])
filename = urllib.parse.unquote_plus(filename)
@srcecde
srcecde / lambda_function.py
Created June 27, 2018 09:11
AWS: Lambda with Comprehend for Batch processing
import boto3
def datachunk(para):
text_list = []
while para:
text_list.append(str(para[:4700]))
para = para[4700:]
return text_list[:25]
def lambda_handler(event, context):
#-*- coding: utf-8 -*-
__author__ = "Chirag Rathod (Srce Cde)"
__license__ = "MIT"
__email__ = "[email protected]"
__maintainer__ = "Chirag Rathod (Srce Cde)"
import json
with open("sample.json", "r") as f:
json_load = json.load(f)
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<br>
<form id="form">
<label id="lbl-name">Name : </label>
<input id="name" type="text" name="name">
from manimlib.scene.scene import Scene
from manimlib.mobject.matrix import Matrix
from manimlib import *
class manim_mobject_matrix_001a(Scene):
def construct(self):
sans = 'monospace'
size = 0.5
play_kw = {"run_time": 0.5}
@srcecde
srcecde / Install ffmpeg & ffprobe on Amazon Linux
Created November 19, 2021 08:19
Install & configure ffmpeg, ffprobe on SageMaker (Amazon Linux)
cd /usr/local/bin
sudo mkdir ffmpeg && cd ffmpeg
# check https://johnvansickle.com/ffmpeg/ for latest build
sudo wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
sudo tar -xf ffmpeg-release-amd64-static.tar.xz
sudo ln -s /usr/local/bin/ffmpeg/ffmpeg-4.4.1-amd64-static/ffmpeg /usr/bin/ffmpeg
sudo ln -s /usr/local/bin/ffmpeg/ffmpeg-4.4.1-amd64-static/ffprobe /usr/bin/ffprobe
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
for record in event['Records']:
body = record['body']
# process message
return {
import os
import json
import boto3
def lambda_handler(event, context):
region_name = os.environ['AWS_REGION']
if event:
sqs = boto3.client('sqs', region_name=region_name)
queue_name = event['Records'][0]['eventSourceARN'].split(':')[-1]
queue_url = sqs.get_queue_url(