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
| function* echoGenerator() { | |
| let received = null; | |
| while (true) { | |
| received = yield received; | |
| if (received === null) return; | |
| received = 'ECHO ' + received; | |
| } |
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/bash | |
| # Loren - 2/12/16 | |
| # you can provide some grep regex as the first arg if you want to delete only | |
| # specific branches | |
| if [ $1 ] | |
| then | |
| branches="git branch | sed 's/^\*//' | grep $1" | |
| else |
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
| #include <stdio.h> | |
| int main() { | |
| int a[4] = { 2, 4, 8, 16 }; | |
| int* b = (int *) a; | |
| b++; | |
| printf("%d", (* b)); |
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
| <?php | |
| $pdo=new PDO("mysql:dbname=markers;host=127.0.0.1","root",""); | |
| $stmt = $pdo->query("SELECT * FROM markers"); | |
| $results = $stmt->fetchAll(PDO::FETCH_ASSOC); | |
| echo json_encode($results); | |
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
| function xhr(params) { | |
| var x = new XMLHttpRequest(); | |
| x.open(params.m, params.p, true); | |
| x.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); | |
| x.send(params.d !== void 0 ? JSON.stringify(params.d) : void 0); | |
| x.onload = function() { | |
| params.fn(x.responseText); | |
| } | |
| }; |
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
| function toSlug(str) { | |
| return str.replace(/[^\w\s\-]/g, ' ') | |
| .split(' ') | |
| .filter(function(substr) { | |
| return (substr.length > 0); | |
| }) | |
| .join('-') | |
| ; | |
| } |
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
| $.ajax('/api/u/', { | |
| type: 'POST', | |
| data: JSON.stringify({}), | |
| headers: { | |
| 'X-XSRF-TOKEN': (function() { | |
| var i = document.cookie.indexOf('XSRF-TOKEN') + 11; | |
| return document.cookie.substring( i , i + 32 ) | |
| })() | |
| }}) | |
| .success(function(r) { |
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
| 3 hr | |
| Models: | |
| Organizer | |
| Group | |
| Contact | |
| Location |
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
| def create_token(length): | |
| return binascii.b2a_hex(os.urandom(int(length / 2))) |
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
| def nearest_square_tuple(val): | |
| nearest_sqrt = int(round(math.sqrt(val))) | |
| nearest_square = nearest_sqrt ** 2 | |
| return (nearest_sqrt, nearest_square) | |
| def delta_square_to_val(val, square): | |
| delta = val - square | |
| return delta | |
| def square_decrement_tuple(val): |