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 random import randint | |
| from time import sleep | |
| from airflow.contrib.hooks.aws_hook import AwsHook | |
| from airflow.exceptions import AirflowException | |
| from airflow.models import BaseOperator | |
| from airflow.utils.decorators import apply_defaults | |
| class AWSGlueCrawlerOperator(BaseOperator): | 
  
    
      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 random import randint | |
| from time import sleep | |
| from airflow.contrib.hooks.aws_hook import AwsHook | |
| from airflow.exceptions import AirflowException | |
| from airflow.models import BaseOperator | |
| from airflow.utils import apply_defaults | |
| class AWSGlueOperator(BaseOperator): | 
  
    
      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
    
  
  
    
  | var Promise = require('bluebird'); | |
| var promiseWhile = function(condition, action) { | |
| var resolver = Promise.defer(); | |
| var loop = function() { | |
| if (!condition()) return resolver.resolve(); | |
| return Promise.cast(action()) | |
| .then(loop) | |
| .catch(resolver.reject); | 
  
    
      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
    
  
  
    
  | # Backup | |
| docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
| # Restore | |
| cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
  
    
      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 solution(A) { | |
| var newArr = A.slice(); //ceates a copy | |
| newArr.sort( function(a, b){return a-b;});//sort the copy | |
| var counter = 0; | |
| for(var i = 0; i < A.length; i++){ //compare to original | |
| if (newArr[i] != A[i]) counter++; | |
| } | |
| return counter > 2 ? false : true; | |
| } | 
  
    
      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
    
  
  
    
  | var list = [1, 4, 8, 33, 2, 1, 5, 7, 8, 6, 3, 2]; | |
| /*VERSION 1 */ | |
| //retains current order of the list | |
| var dups = {}; //create an object, purpose is we want keys | |
| var uniques = list.filter(function(item){ | |
| return dups.hasOwnProperty(item) ? false : dups[item] = true; | |
| }); | |
| /* How does this work? | 
  
    
      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 permute(str){ | |
| var len = Math.pow(2, str.length); //possibilities = 2^n | |
| var permutations = []; | |
| for(var i = 0; i < len; i++){ | |
| var binaryStr = i.toString(2); //get binary representation | |
| var mask = new Array(binaryStr.length+1).join('0'); //get a string of zeroes | |
| binaryStr = mask.substr(binaryStr.length)+binaryStr; //now we have leading 00's | |
| var permStr = ''; | |
| for(j = 0; j < binaryStr.length; j++){ |