Skip to content

Instantly share code, notes, and snippets.

View tmocellin's full-sized avatar

Thibault tmocellin

  • Freelance React JS / Native
  • France
View GitHub Profile
const response = [];
var promises = [];
var i = 44;
while(i <= 46){
promises.push(
fetch('https://jsonplaceholder.typicode.com/posts/'+i.toString()).then(result =>{
return result.json()
}).then( jsonResult => {
return jsonResult;
})
var cWrap=$('<pre>');
$('.w-richtext h6').each(function(){
var o = $(this).next('h6').length;
console.log(o);
$(this).replaceWith(cWrap).appendTo(cWrap);
if (!o) cWrap=$('<pre />');
});
{
"workbench.iconTheme": "material-icon-theme",
"workbench.welcome.enabled": false,
"editor.fontSize": 13,
"editor.tabSize": 2,
"editor.wordWrapColumn": 80,
"editor.snippetSuggestions": "top",
"editor.minimap.enabled": true,
"files.exclude": {
"**/.git": true,
var e = document.createElement('script');
e.setAttribute('src', 'https://nytimes.github.io/svg-crowbar/svg-crowbar.js');
e.setAttribute('class', 'svg-crowbar');
document.body.appendChild(e);
@tmocellin
tmocellin / ScrapRb.rb
Created December 31, 2015 15:44
Skeleton rake task for scrapping website with nokogiri
require 'open-uri'
require 'nokogiri'
require 'securerandom'
namespace :Scrap do
desc "code structure for new scrapper"
task :sample => :environment do
src = "" # define the source of the article
url_to_scrap = "" # define the url where scrap the article can be the same as src
@tmocellin
tmocellin / scraper.rb
Created December 16, 2015 22:32
Simple test scraping whith nokogiri
require 'open-uri'
require 'nokogiri'
def getPageResult (html_data)
$data_array = []
list_ads = html_data.css('.list-lbc a')
list_ads.each { |add|
url = add['href']
title = add.css('.detail .title').text.gsub(/\s+/,' ')
@tmocellin
tmocellin / React Scroll Event
Created August 3, 2015 14:05
Handle the scroll event in react js and change the navbar class when special section is on top of windows
var Hello = React.createClass({
getOffset : function(element){
var bounding = element.getBoundingClientRect();
return {
top: bounding.top + document.body.scrollTop,
left: bounding.left + document.body.scrollLeft
};
},
.ui-datepicker {
background-color: #fff;
border: 1px solid #66AFE9;
border-radius: 4px;
box-shadow: 0 0 8px rgba(102,175,233,.6);
display: none;
margin-top: 4px;
padding: 10px;
width: 240px;
}