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
extension UIImage { | |
func resizeCI(size:CGSize) -> UIImage? { | |
let scale = (Double)(size.width) / (Double)(self.size.width) | |
let image = UIKit.CIImage(CGImage:self.CGImage!) | |
let filter = CIFilter(name: "CILanczosScaleTransform")! | |
filter.setValue(image, forKey: kCIInputImageKey) | |
filter.setValue(NSNumber(double:scale), forKey: kCIInputScaleKey) | |
filter.setValue(1.0, forKey:kCIInputAspectRatioKey) | |
let outputImage = filter.valueForKey(kCIOutputImageKey) as! UIKit.CIImage |
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
func imageFromSampleBuffer(sampleBuffer:CMSampleBufferRef) -> UIImage? { | |
if let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { | |
CVPixelBufferLockBaseAddress(imageBuffer,0) | |
let baseAddress = CVPixelBufferGetBaseAddress(imageBuffer) | |
let bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer) | |
let width = CVPixelBufferGetWidth(imageBuffer) | |
let height = CVPixelBufferGetHeight(imageBuffer) | |
let colorSpace = CGColorSpaceCreateDeviceRGB() | |
let context = CGBitmapContextCreate(baseAddress,width,height,8,bytesPerRow, colorSpace, CGBitmapInfo.ByteOrder32Little.rawValue | CGImageAlphaInfo.PremultipliedFirst.rawValue) |
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
cd / | |
find . -name figma-linux_figma-linux.desktop 2>/dev/null | |
less ./var/lib/snapd/desktop/applications/figma-linux_figma-linux.desktop | |
cat ./var/lib/snapd/desktop/applications/figma-linux_figma-linux.desktop | |
ls -l ./var/lib/snapd/desktop/applications/figma-linux_figma-linux.desktop | |
sudo cp ./var/lib/snapd/desktop/applications/figma-linux_figma-linux.desktop ~/.local/share/applications | |
vim ~/.local/share/applications/mimeapps.list | |
xdg-mime default figma-linux_figma-linux.desktop x-scheme-handler/figma | |
xdg-mime query default x-scheme-hander/figma | |
cat /usr/share/applications/figma-linux.desktop || cat /var/lib/snapd/desktop/applications/figma-linux_figma-linux.desktop\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
K:=kubectl | |
NS:=default | |
.PHONY: migrate | |
migrate: | |
$(K) apply -f migration/migration-job.yaml -n $(NS) | |
$(K) wait --for=condition=complete --timeout=300s jobs/mlserver-migration -n $(NS) | |
$(K) get job mlserver-migration -o "jsonpath={.metadata.labels.controller-uid}" -n $(NS) \ | |
| xargs -I {} $(K) get po -l controller-uid={} -o "jsonpath={.items[0].metadata.name}" -n $(NS) \ | |
| xargs -I {} $(K) logs {} -n $(NS) -c mlserver-django \ |
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
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: mlserver-migration | |
spec: | |
parallelism: 1 | |
template: | |
spec: | |
containers: | |
- name: cloudsql-proxy |
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 PlanViewset(viewsets.ModelViewSet): | |
class Schema(AutoSchema): | |
def get_operation(self, path, method): | |
op = super().get_operation(path, method) | |
if method == "GET" and path.split('/')[-2] != '{id}': | |
op['parameters'].append({ | |
"name": "time_window_id", | |
"in": "query", |
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
countries = [ | |
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'}, | |
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'}, | |
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"}, | |
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'}, | |
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'}, | |
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'}, | |
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai |
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 python:3.8-buster | |
RUN apt-get update && apt-get install -y --no-install-recommends openssh-server | |
RUN mkdir -p /run/sshd && mkdir -p /var/run/sshd && mkdir -p /root/.ssh | |
ARG PWD | |
RUN ssh-keygen -A | |
RUN echo "root:$PWD" | chpasswd | |
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config | |
EXPOSE 22 |
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
extension UIImage { | |
func resizeVI(size:CGSize) -> UIImage? { | |
let cgImage = self.CGImage! | |
var format = vImage_CGImageFormat(bitsPerComponent: 8, bitsPerPixel: 32, colorSpace: nil, | |
bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.First.rawValue), | |
version: 0, decode: nil, renderingIntent: CGColorRenderingIntent.RenderingIntentDefault) | |
var sourceBuffer = vImage_Buffer() | |
defer { | |
sourceBuffer.data.dealloc(Int(sourceBuffer.height) * Int(sourceBuffer.height) * 4) |
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
export NAME=gurkha | |
conda create -n gurkha python=3.6 | |
conda activate gurkha | |
conda install opencv | |
pip install moviepy | |
pip install matplotlib | |
pip install jupyter | |
pip install jupyter_contrib_nbextensions | |
pip install nbextension install | |
jupyter contrib nbextension install |
NewerOlder