Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Victor Mus sdwvit

🏠
Working from home
View GitHub Profile
@sdwvit
sdwvit / generate.sh
Created Oct 30, 2019
Generate cacheable key for CI depending on versioned files diff
View generate.sh
#!/bin/sh
a="$(git diff master... --numstat | awk 'NF==3 {total+=$1+$2} END {printf("%d\n", total)}')" \
if [ "$a" -gt 100 ]
then
echo "bust $(date +%s)" > gitdiff
else
echo "keep" > gitdiff
fi
View hyi.js
let test = [[3, [666, 123, 57, 191919, 2]]];
function gcd(a, b) {
while (true) {
if (a !== 0 && b !== 0) {
if (a > b) {
a = a % b;
} else {
b = b % a;
}
View crack.c
#include <cs50.h>
#include <stdio.h>
#include <crypt.h>
#include <string.h>
int A_charcode = 65;
int a_charcode = 97;
int abc_size = 25;
string hash;
bool success = false;
View mario.c
#include <stdio.h>
#include <stdlib.h>
#include <cs50.h>
int getHeight(void) {
int height;
do {
height = get_int("Height: ");
} while (
View сс.c
#include <stdio.h>
#include <stdlib.h>
#include <cs50.h>
string INVALID = "INVALID";
string AMEX = "AMEX";
string MASTERCARD = "MASTERCARD";
string VISA = "VISA";
typedef struct {
View generate-branch-name.js
const login = 'sdwvit';
const type = {
feat: 'feature',
chore: 'chore',
main: 'maintenance',
fix: 'fix'
};
const pages = {
land: 'landing',
res: 'results',
View Geocoder response
/**/_xdc_._tumftg && _xdc_._tumftg( {
"results" : [
{
"address_components" : [
{
"long_name" : "New York",
"short_name" : "New York",
"types" : [ "locality", "political" ]
},
{
View Predictions
/**/_xdc_._3c1ih2 && _xdc_._3c1ih2( {
"predictions" : [
{
"description" : "New York, NY, USA",
"id" : "7eae6a016a9c6f58e2044573fb8f14227b6e1f96",
"matched_substrings" : [
{
"length" : 8,
"offset" : 0
}
View gist:5b64f52d42b5a29c98b9d2fd094f15a9
[
[88.5, 4.16, 1.54],
[-6.2, 12.75, 3.09],
[50.08, 17.69, 3.11],
[8.81, 4.93, 3.13],
[37.71, 6.87, 3.18],
[88.5, 4.16, 3.21],
[50.08, 17.69, 3.79],
[8.81, 4.93, 4.29],
[8.81, 4.93, 4.85],
@sdwvit
sdwvit / gmaps_static_signing_url_with_fastly.vcl
Created Apr 10, 2018
Signing google static maps URL with fastly
View gmaps_static_signing_url_with_fastly.vcl
sub vcl_recv {
# Creates google static maps API signature and adds it as one of the query params on the fly. Basically signs URL.
# Key is here: https://consers.google.com/apis/api/static-maps-backend.googleapis.com/ole.developstaticmap/ your_project
set req.http.signature = digest.hmac_sha1_base64(digest.base64_decode("YOUR_KEY"), req.url);
# Create safe-for-web version of the key by replacing '+' -> '-', and '\' -> '_'.
set req.http.signature_url_safe = regsuball(regsuball(req.http.signature, "\+", "-"), "\\", "_");
# Add signature query param to the request url
You can’t perform that action at this time.