This file contains hidden or 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
| // For library: https://github.com/danielgindi/Charts | |
| extension BarLineChartViewBase { | |
| func focusXRange(start: Double, end: Double) { | |
| guard end > start else { | |
| return | |
| } | |
| // Reset the zoom back to the full chart view, so that the setVisibleXRange call will zoom in to the desired range, | |
| // setVisibleXRange only zooms in, not out. |
This file contains hidden or 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 Array where Element: Comparable { | |
| // Returns the location of the value in the array, | |
| // or where you should insert the value into the array. | |
| // If the value does not exist in the array, the Bool return value is false. | |
| func binarySearch(value: Element) -> (Index, Bool) { | |
| guard !isEmpty else { | |
| return (0, false) | |
| } | |
| if value > self.last! { |
This file contains hidden or 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 UUID { | |
| // UUID is 128-bit, we need two 64-bit values to represent it | |
| var integers: (Int64, Int64) { | |
| var a: UInt64 = 0 | |
| a |= UInt64(self.uuid.0) | |
| a |= UInt64(self.uuid.1) << 8 | |
| a |= UInt64(self.uuid.2) << (8 * 2) | |
| a |= UInt64(self.uuid.3) << (8 * 3) | |
| a |= UInt64(self.uuid.4) << (8 * 4) | |
| a |= UInt64(self.uuid.5) << (8 * 5) |
This file contains hidden or 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 Int64 { | |
| /* | |
| Returns the absolute distance between two Int64 values as a UInt64. | |
| A UInt64 is required to represent the range of possible distance values. | |
| */ | |
| func distanceTo(_ other: Int64) -> UInt64 { | |
| if self == other { | |
| return 0 | |
| } | |
| if self > other { |
This file contains hidden or 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
| #!/bin/sh | |
| # Original: https://gohugo.io/hosting-and-deployment/hosting-on-github/#put-it-into-a-script | |
| # If a command fails then the deploy stops | |
| set -e | |
| printf "\033[0;32mDeploying updates to GitHub...\033[0m\n" | |
| # Clean the public folder |
This file contains hidden or 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
| playbook | |
| ├── roles | |
| │ ├── createuser | |
| │ │ ├── tasks | |
| │ │ │ └── main.yml | |
| │ │ └── templates | |
| │ │ └── sudoers.j2 | |
| │ └── maybecreateuser | |
| │ └── tasks | |
| │ └── main.yml |
This file contains hidden or 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
| -- Found PkgConfig: /usr/bin/pkg-config (found version "0.26") | |
| PROCESSOR: x86_64 | |
| Machine: x86_64-linux-gnu | |
| -- Target host is 64 bit | |
| -- Looking for include file stdint.h | |
| -- Looking for include file stdint.h - found | |
| -- Looking for include file stdlib.h | |
| -- Looking for include file stdlib.h - found | |
| -- Looking for include file pthread.h | |
| -- Looking for include file pthread.h - found |
This file contains hidden or 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 sys import argv | |
| from string import ascii_uppercase | |
| def map_number(number): | |
| """ Maps a number's digits to its possible phone letters """ | |
| sets = [] | |
| for n in str(number): | |
| assert n != '0' | |
| pos = (int(n) - 1) * 3 |
This file contains hidden or 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
| unsigned char* hexstr_to_char(const char* hexstr) | |
| { | |
| size_t len = strlen(hexstr); | |
| IF_ASSERT(len % 2 != 0) | |
| return NULL; | |
| size_t final_len = len / 2; | |
| unsigned char* chrs = (unsigned char*)malloc((final_len+1) * sizeof(*chrs)); | |
| for (size_t i=0, j=0; j<final_len; i+=2, j++) | |
| chrs[j] = (hexstr[i] % 32 + 9) % 25 * 16 + (hexstr[i+1] % 32 + 9) % 25; | |
| chrs[final_len] = '\0'; |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import sys | |
| from forq import db, create_app | |
| def drop(): | |
| db.drop_all() | |
| print 'Dropping completed successful!' |
NewerOlder