Skip to content

Instantly share code, notes, and snippets.

View gangstaJS's full-sized avatar

Oleksandr Shapovalenko gangstaJS

View GitHub Profile
@NegatioN
NegatioN / install.sh
Last active October 11, 2024 16:28
Installing Canon Printers Ubuntu
# Origin http://ubuntuhandbook.org/index.php/2020/05/canon-printer-scangear-mp-ubuntu-20-04/
# Ubuntu
sudo apt install printer-driver-gutenprint
sudo add-apt-repository ppa:thierry-f/fork-michael-gruz
sudo apt install scangearmp2
sudo apt install scangearmp-mp495series
# Arch / Manjaro
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import SphericalMercator from "@mapbox/sphericalmercator";
import { MapView, Constants } from "expo";
const merc = new SphericalMercator();
const getZoomLevelFromRegion = (region, viewport) => {
const { longitudeDelta } = region;
const { width } = viewport;
@flaviocopes
flaviocopes / check-substring-ends-with.go
Last active November 15, 2021 09:34
Go: check if a string ends with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasSuffix("foobar", "bar") // true
}
@mmcloughlin
mmcloughlin / methodasfunc.go
Last active June 15, 2018 15:51
Golang method expressions satisfy function types
package main
import "fmt"
// GreetingFunc builds a greeting from a name.
type GreetingFunc func(string) string
// Formatted builds a greeting based on a printf-style format string.
type Formatted struct {
Format string
@heron2014
heron2014 / react-native-maps-enable-google-maps-instructions.md
Last active October 5, 2025 19:23
Visual instructions how to enable Google Maps on IOS using react-native-maps

Visual instructions how to enable Google Maps on IOS using react-native-maps

UPDATE: Following instructions are now a year old. I have recently managed to upgrade react-native-maps from 0.17 to the latest version 0.21 with react-native 0.51 - if you want to follow my instruction scroll down to the end this doc! Hope that will work for you too!

This is for my personal use, things might not be correctly explained here. For the official docs please check https://github.com/airbnb/react-native-maps

Steps from scratch:

1.react-native init GoogleMapPlayground

@xgrommx
xgrommx / ranges.js
Last active June 13, 2020 23:04
Generate ranges in javascript
const range1 = len => Object.keys(new Int8Array(len)).map(parseFloat);
const range2 = len => Array.apply(null, {length: len}).map(Number.call, Number);
const range3 = (start, end) => Array.apply(null, Array(end - start)).map((_, i) => start + i);
const range4 = (start, end) => [...Array(end - start)].map((_, i) => start + i);
const range5 = len => Object.keys(Array.apply(null, Array(len)));
@volter9
volter9 / example.php
Last active April 30, 2019 21:24
Cool validation module
<?php
require 'validation.php';
/** An example, validate the given data with given rules */
$data = [
'username' => 'voteforpedro',
'password' => '123456',
'confirm' => '123456',
@jed
jed / progress.js
Last active March 11, 2016 08:37
Using template strings as progress bars
"use strict"
function progress(strs, current, total) {
let str = `${strs[0]}${current}${strs[1]}${total}${strs[2]}`
let ratio = Math.min(Math.max(current / total, 0), 1)
let length = Math.floor(ratio * str.length)
let pattern = new RegExp(`^.{${length}}`)
return str.replace(pattern, "\x1b[4m$&\x1b[0m")
}
@santthosh
santthosh / apache rewrite rule
Created November 14, 2014 08:38
Apache config for SPA's
# To be inside the /Directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master