Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Om4ar / ffmpeg.md
Created February 15, 2018 23:07 — forked from neilrenicker/ffmpeg.md
How to convert an m4a file to an mp3 using ffmpeg

Convert an m4a file to an mp3 using ffmpeg

  • Install ffmpeg using homebrew:
brew install ffmpeg
  • convert the file:
// array , property string
// https://medium.com/javascript-inside/safely-accessing-deeply-nested-values-in-javascript-99bf72a0855a
const get = (p, o) =>
p.reduce((xs, x) => (xs && xs[x]) ? xs[x] : null, o)
// let's pass in our props object...
console.log(get(['user', 'posts', 0, 'comments'], props))
// [ 'Good one!', 'Interesting...' ]
console.log(get(['user', 'post', 0, 'comments'], props))
// null
@Om4ar
Om4ar / jsx
Created March 6, 2018 15:40
example of function component with full settings
import React from "react";
import PropTypes from "prop-types";
import Chip from "material-ui/Chip";
import { withStyles } from "material-ui/styles";
const styles = theme => ({
root: {
display: "flex",
flexWrap: "wrap"
},
@Om4ar
Om4ar / jsx
Created March 6, 2018 15:40
example of function component with full settings
import React from "react";
import PropTypes from "prop-types";
import Chip from "material-ui/Chip";
import { withStyles } from "material-ui/styles";
const styles = theme => ({
root: {
display: "flex",
flexWrap: "wrap"
},
@Om4ar
Om4ar / ImageUploadComponent.jsx
Created March 8, 2018 11:06 — forked from hartzis/ImageUploadComponent.jsx
React Image Uploading Component with Image Preview
class ImageUpload extends Component {
constructor(props) {
super(props);
this.state = {
file: '',
imagePreviewUrl: ''
};
this._handleImageChange = this._handleImageChange.bind(this);
this._handleSubmit = this._handleSubmit.bind(this);
}
@Om4ar
Om4ar / strtotime.php
Created March 26, 2018 20:38 — forked from garak/strtotime.php
never use '+1 month' and '-1 month' in strtotime. It's just bugged
<?php
// tried this today, 31 May 2011
echo "\n";
echo date('Y-m-d', strtotime('first day of next month')); // correct
echo "\n";
echo date('Y-m-d', strtotime('+1 month')); // wrong! output is 2011-07-01
echo "\n";
@Om4ar
Om4ar / mongodb.service
Created April 25, 2018 01:51 — forked from Genda1ph/mongodb.service
MongoDB systemd service unit configuration
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
Type=simple
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/lib/mongodb
ExecStartPre=/bin/chown mongodb:mongodb /var/lib/mongodb
@Om4ar
Om4ar / mongodb.service
Created April 25, 2018 01:51 — forked from jwilm/mongodb.service
MongoDB systemd service unit configuration
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
Type=forking
PIDFile=/var/run/mongodb/mongod.pid
ExecStart=/usr/local/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
@Om4ar
Om4ar / immutable react update state cheat sheet
Created May 7, 2018 16:17
immutable react update state cheat sheet
Immutable Update Cheat Sheet / Receipes
Objects
Updating object property
// Alternative #1
return {...originalObject, existingPropertyKey: newValue };
// Alternative #2
return Object.assign({}, originalObject, { existingPropertyKey: newValue }); // Notice extra { } around properties
Updating nested object property
For nested fields you need to remember to copy every level, read more here.
@Om4ar
Om4ar / php curl post
Created June 14, 2018 10:28 — forked from jarontai/php curl post
php curl post
function post_to_url($url, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);