Skip to content

Instantly share code, notes, and snippets.

View rsmelo92's full-sized avatar
🌎

Rafael Melo rsmelo92

🌎
View GitHub Profile
@rsmelo92
rsmelo92 / gist.js
Last active February 6, 2018 20:30
Enter Key Event jquery
$(‘input’).on(‘keypress’, (event)=> {
if(event.which === 13){
//Do Something
}
});
@rsmelo92
rsmelo92 / form.html
Created February 6, 2018 20:32
form
<form>
<input type=”text”>
<button type=”submit”>
Search!
</button>
</form>
@rsmelo92
rsmelo92 / form.js
Created February 6, 2018 20:33
form enter key event
$(‘form’).on(‘submit’, (event)=>{
event.preventDefault();
// Do what you want here
// In this case get input value
// Do a search
// Redirect to results page
});
@rsmelo92
rsmelo92 / recordScreen.sh
Created July 11, 2019 16:21
Script to record simulator screen as gif on macos
#!/bin/bash
cd $HOME/Documents/Record_screen
echo "Recording. To stop and save it press CTRL+C"
xcrun simctl io booted recordVideo out.mov
ffmpeg -i out.mov -vf scale=320:-1 -r 10 "record_"$(date '+%W_%Y_%X').gif
rm out.mov
open $HOME/Documents/Record_screen
cd -
describe('province', function() {
it('shortfall', function() {
const asia = new Province(sampleProvinceData());
expect(asia.shortfall).equal(5);
});
it('profit', function() {
const asia = new Province(sampleProvinceData());
expect(asia.profit).equal(230);
});
describe('province', function() {
const asia = new Province(sampleProvinceData()); // DON'T DO THIS!
it('shortfall', function() {
expect(asia.shortfall).equal(5);
});
it('profit', function() {
expect(asia.profit).equal(230);
});
});
describe('province', function() {
let asia;
beforeEach(function() {
asia = new Province(sampleProvinceData());
});
it('shortfall', function() {
expect(asia.shortfall).equal(5);
});
it('profit', function() {
// *SMELL*
function tc(f) {
return (5 / 9) * (f - 32);
}
// *REFACTORED*
function toCelsius(farenheit) {
return (5 / 9) * (farenheit - 32);
}
// *SMELL*
function sumOfPowers() {
let firstPower;
for (let index = 1; index < 3; index++) {
firstPower = firstPower * number;
}
let secondPower;
for (let index = 1; index < 3; index++) {
secondPower = firstPower * number;
@rsmelo92
rsmelo92 / loop.js
Last active January 13, 2020 15:13
// *SMELL*
function filterCurseWords(words) {
for (let index = 0; index < words.length; index++) {
if(words[index] === "curse word"){
words.splice(index)
}
}
return words;
}