Skip to content

Instantly share code, notes, and snippets.

Mannuel Ferreira mannuelf

Block or report user

Report or block mannuelf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mannuelf
mannuelf / change-author.sh
Created May 12, 2019
Changing author info
View change-author.sh
git filter-branch --env-filter '
WRONG_EMAIL="wrong@example.com"
NEW_NAME="New Name Value"
NEW_EMAIL="correct@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@mannuelf
mannuelf / new_gist_file_0
Last active Jan 18, 2018
update urls in database mysql
View new_gist_file_0
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');
UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');
View script.js
dropzone.on("addedfile", function(origFile) {
var MAX_WIDTH = 800;
var MAX_HEIGHT = 600;
var reader = new FileReader();
// Convert file to img
reader.addEventListener("load", function(event) {
@mannuelf
mannuelf / some.js
Created Jan 10, 2017
In Progress Network Requests: Given an array of network objects representing network requests, assign the boolean 'true' to the variable 'inProgress' if any network request has a 'status' of 'pending'.
View some.js
var requests = [
{ url: '/photos', status: 'complete' },
{ url: '/albums', status: 'pending' },
{ url: '/users', status: 'failed' }
];
var inProgress = requests.some(function(status) {
return status != 'pending';
});
@mannuelf
mannuelf / find-specific.js
Created Jan 1, 2017
find a specific post or thing in an array
View find-specific.js
const posts = [
{ id: 1, title: 'New Post'},
{ id: 2, title: 'Old Post'},
];
const comment = { postId: 1, content: 'what great reading' };
function postForComment(posts, comment) {
return posts.find(function(post) {
return post.id === comment.postId;
View find-cars.js
function Car(model) {
this.model = model;
}
var cars = [
new Car('Ferrari'),
new Car('McLaren'),
new Car('Porsche')
];
View find.js
var users = [
{ name: 'Alan', surname: 'Shearer' },
{ name: 'Micheal', surname: 'Owen' },
{ name: 'Peter', surname: 'Beardsley' }
];
var user;
/*
for (var i = 0; i < users.length; i++) {
@mannuelf
mannuelf / filter-reject.js
Created Jan 1, 2017
Create a function called 'reject'. Reject should work in the opposite way of 'filter' - if a function returns 'true', the item should *not* be included in the new array.
View filter-reject.js
const numbers = [ 10, 20, 30, 40, 50, 60 ];
function reject(numbers, iteratorFunction) {
return numbers.filter(function(number){
return (number < 15);
});
}
@mannuelf
mannuelf / filter-permissions.js
Created Jan 1, 2017
Handling Permissions with Filter
View filter-permissions.js
const users = [
{ id: 1, admin: true },
{ id: 2, admin: false },
{ id: 3, admin: false },
{ id: 4, admin: false },
{ id: 5, admin: true },
];
let filteredUsers = users.filter(function(user) {
return user.admin === true;
@mannuelf
mannuelf / filter-values.js
Created Jan 1, 2017
Filtering Values. Filter the array of numbers using the filter helper, creating a new array that only contains numbers greater than 50. Assign this new array to a variable called 'filteredNumbers'. Don't forget to use the 'return' keyword in the function!
View filter-values.js
const numbers = [15, 25, 35, 45, 55, 65, 75, 85, 95];
let filteredNumbers = numbers.filter(function(number) {
return number > 50;
});
console.log(filteredNumbers);
You can’t perform that action at this time.