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
| import asyncio | |
| import logging | |
| import signal | |
| logger = logging.getLogger(__name__) | |
| class EventLoop: | |
| def __init__(self, loop=None, debug=False): | |
| self.loop = loop or asyncio.get_event_loop() |
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
| # configuration params are copied from @artgor kernel: | |
| # https://www.kaggle.com/artgor/brute-force-feature-engineering | |
| LGB_PARAMS = { | |
| 'objective': 'regression', | |
| 'metric': 'mae', | |
| 'verbosity': -1, | |
| 'boosting_type': 'gbdt', | |
| 'learning_rate': 0.2, | |
| 'num_leaves': 128, | |
| 'min_child_samples': 79, |
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 concurrent.futures import ThreadPoolExecutor, Executor, Future | |
| class Promise: | |
| def __init__(self, fn, *args, **kwargs): | |
| self.fn = fn | |
| self.callbacks = [] | |
| self.last_result = None | |
| self.executor: Executor = ThreadPoolExecutor(max_workers=1) | |
| self.future: Future = self.executor.submit(fn, *args, **kwargs) |
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
| Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, deep, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r, gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnupl |
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 tempfile import NamedTemporaryFile, TemporaryDirectory | |
| def compose(g, f): | |
| """Right to left function composition.""" | |
| return lambda *args, **kwargs: g(f(*args, **kwargs)) | |
| def temporarify(action, directory=False): | |
| """ |
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
| DECLARE | |
| statements CURSOR FOR | |
| SELECT tablename FROM pg_tables | |
| WHERE schemaname = 'public'; | |
| BEGIN | |
| FOR stmt IN statements LOOP | |
| EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; | |
| EXECUTE 'ALTER SEQUENCE ' || quote_ident('' || stmt.tablename || '_id_seq') || ' RESTART WITH 1'; | |
| END LOOP; | |
| END; |
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 numberOne = +'1'; // 1 |
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
| @keyframes dropball { | |
| 0% { | |
| bottom: 200px; | |
| } | |
| 2% { | |
| bottom: 198.89046144485474px; | |
| } | |
| 4% { | |
| bottom: 197.5577425956726px; | |
| } |
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 tenDaysAgo = new Date( now.getFullYear(), now.getMonth(), now.getDate() - 10); // Negative date works !! | |
| var negativeDate = new Date(2015, 10, -1); // 30 Octobre 2015 | |
| var elappsedTime = Date.now() - tenDaysAgo; // Soustraire deux dates utilisent automatiquement les timeStamps |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |