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 JavaScript from 'tree-sitter-javascript'; | |
import TypeScript from 'tree-sitter-typescript'; | |
import Python from 'tree-sitter-python'; | |
import Go from 'tree-sitter-go'; | |
import Swift from 'tree-sitter-swift'; | |
import Java from 'tree-sitter-java'; | |
import Kotlin from 'tree-sitter-kotlin'; | |
import C from 'tree-sitter-c'; | |
import CPlusPlus from 'tree-sitter-cpp'; | |
import Rust from 'tree-sitter-rust'; |
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 torch | |
from torch.nn.functional import normalize | |
from .unixcoder import UniXcoder | |
class UniXcoderEmbeddings: | |
def __init__(self, model_name="microsoft/unixcoder-base"): | |
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
self.model = UniXcoder(model_name).to(self.device) | |
def get_embedding(self, text): |
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 ubuntu:focal AS build | |
USER root | |
RUN apt-get update && apt-get install -y build-essential g++-multilib-x86-64-linux-gnu curl | |
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y | |
ENV PATH="/root/.cargo/bin:${PATH}" | |
RUN rustup target add x86_64-unknown-linux-gnu | |
RUN curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2.8_amd64.deb -O \ | |
&& curl http://security.debian.org/debian-security/pool/updates/main/z/zeromq3/libzmq3-dev_4.2.1-4+deb9u4_amd64.deb -O \ |
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
const int basePin = 2; | |
void triggerRemote() { | |
digitalWrite(basePin, HIGH); | |
delay(2000); | |
digitalWrite(basePin, LOW); | |
} | |
void setup() { | |
pinMode(basePin, OUTPUT); |
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 django.conf import settings | |
"""Delete sessionid and csrftoken cookies on logout, for better compatibility with upstream caches.""" | |
class DeleteSessionOnLogoutMiddleware(object): | |
def process_response(self, request, response): | |
if getattr(request, '_delete_session', False): | |
response.delete_cookie(settings.CSRF_COOKIE_NAME, domain=settings.CSRF_COOKIE_DOMAIN) | |
response.delete_cookie(settings.SESSION_COOKIE_NAME, settings.SESSION_COOKIE_PATH, settings.SESSION_COOKIE_DOMAIN) | |
return response |
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
sub vcl_recv { | |
# unless sessionid/csrftoken is in the request, don't pass ANY cookies (referral_source, utm, etc) | |
if (req.request == "GET" && (req.url ~ "^/static" || (req.http.cookie !~ "sessionid" && req.http.cookie !~ "csrftoken"))) { | |
remove req.http.Cookie; | |
} | |
# normalize accept-encoding to account for different browsers | |
# see: https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeAcceptEncoding | |
if (req.http.Accept-Encoding) { | |
if (req.http.Accept-Encoding ~ "gzip") { |