Skip to content

Instantly share code, notes, and snippets.

@javascriptlove
javascriptlove / android_fix_google_play_services.js
Last active July 16, 2019 11:45
Fix Meteor build on Android after Google published com.google.android.gms:play-services-auth:17 and com.google.android.gms:play-services-identity:17
#!/usr/bin/env node
// .meteor/android_fix_google_play_services.js
console.log('Running android_fix_google_play_services.js to use exact play services version for current Meteor target SDK 26');
var fs = require('fs');
var pluginxml = 'plugins/cordova-plugin-googleplus/plugin.xml';
var gradlePath = 'platforms/android/build.gradle';
var projectProps = 'platforms/android/project.properties';
@javascriptlove
javascriptlove / main.js
Created September 19, 2018 13:36
Remove duplicate lines from file
const fs = require('fs');
const lines = fs.readFileSync('source.txt', { encoding: 'utf8' });
const unique_lines = [...new Set(lines.split("\n"))];
fs.writeFileSync('output.txt', unique_lines.join(","));
@javascriptlove
javascriptlove / .htaccess
Created July 11, 2018 19:00
Redirect from/to www
# www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# non-www to www:
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
@javascriptlove
javascriptlove / README.md
Last active June 28, 2018 12:25
Basic Jasmine tests to be run on Bamboo with JUnit reporter test parser

1. App structure like this:

/app
/app/index.js
/app/package.json
/app/spec/helpers/junit_reporter.js
/app/spec/support/jasmine.json
/app/spec/tests/helloworld.spec.js
@javascriptlove
javascriptlove / example.conf
Created June 12, 2018 17:56
Configure Apache SSL using Webmin's Let's Encrypt certificate
<VirtualHost *:80>
DocumentRoot /path/to/www/
ServerName domain.com
ServerAlias www.domain.com
<Directory "/path/to/www/">
Options FollowSymLinks MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
@javascriptlove
javascriptlove / cleanup.js
Created May 22, 2018 13:07
Remove orphan GridFS chunks from MongoDB
var i = 0;
var orphans = 0;
db.fs.chunks.find({}, { files_id: 1 }).forEach(function(chunk) {
i++;
if (i % 100 === 0) {
print(i);
}
if (!db.fs.files.findOne({ _id: chunk.files_id }, { _id: 1 })) {
print("orphan " + chunk._id);
db.fs.chunks.remove({ _id: chunk._id });
@javascriptlove
javascriptlove / README.md
Created May 9, 2018 21:04
Drupal malware scanner

Simple scanner to find potentially unsafe files inside a Drupal installation. Each output should be manually processed.

Example

php drupalscanner.php myfolder

@javascriptlove
javascriptlove / README.md
Last active March 2, 2017 10:37
Getting http response code with Selenium and Expose Response Headers extension