Skip to content

Instantly share code, notes, and snippets.

View celian-m's full-sized avatar

celian celian-m

  • MyStudioFactory
  • Paris
View GitHub Profile
@celian-m
celian-m / index.sh
Created July 24, 2024 17:22 — forked from michael-sumner/index.sh
WP-CLI command to loop through all sites in the multisite network and use wp db query to obtain a list of posts, and save them in log.txt file
# replace "Hello, World!" with appropriate string to search for
# replace `post_title` with appropriate column to search for
wp site list --fields=url,blog_id | while IFS= read -r line; do
url=$(echo "$line" | awk -F'\t' '{print $1}')
blog_id=$(echo "$line" | awk -F'\t' '{print $2}')
wp post list --field=url --ignore_sticky_posts=1 --orderby=date --order=DESC --post__in=$(wp db query "SELECT ID FROM wp_${blog_id}_posts WHERE post_title LIKE '%Hello, World!%' AND post_status='publish' AND post_type='post'" --skip-column-names --url=${url} | paste -s -d ',' -) --url=${url}
done >> log.txt

Create an Alias for your host adress (on your mac)

sudo ifconfig lo0 alias 10.254.254.254

Create a Launch Configuration for VS Code

{
    "name": "Listen for Xdebug",
    "type": "php",
 "request": "launch",
@celian-m
celian-m / UIScrollViewDelegate.swift
Created March 21, 2019 09:21
Add custom page size to UIScrollview
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
// Page width used for estimating and calculating paging.
let pageWidth = (self.frame.width) - interIntemMargin
// Make an estimation of the current page position.
let approximatePage = scrollView.contentOffset.x/pageWidth
// Determine the current page based on velocity.
let currentPage = (velocity.x < 0.0) ? floor(approximatePage) : ceil(approximatePage)
@celian-m
celian-m / LeftAlignedCollectionViewFlowLayout.swift
Created March 19, 2019 08:56
Left Align cells for UICollection View
import UIKit
class LeftAlignedCollectionViewFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
guard let superArray = super.layoutAttributesForElements(in: rect),
let attributes = NSArray(array: superArray, copyItems: true) as? [UICollectionViewLayoutAttributes] else { return nil }
var leftMargin = sectionInset.left
var maxY: CGFloat = -1.0
@celian-m
celian-m / RxUseCase.swift
Created December 20, 2018 09:13
Rx variation for UseCase declaration
import Foundation
import RxSwift
enum Either<T> {
case success(T)
case error(Swift.Error)
var successResult: T? {
switch self {
case .success(let result):
import Foundation
enum Either<T> {
case success(T)
case error(Swift.Error)
var successResult: T? {
switch self {
case .success(let result):
return result
case .error(_):
@celian-m
celian-m / generate_package.md
Last active September 6, 2017 07:58
Generate a Swift project

Create directory

$mkdir myProject

Go in

$cd myProject

Init the project

@celian-m
celian-m / Readme.md
Created July 3, 2017 12:20
IOS Usefull Links
@celian-m
celian-m / Git.sh
Last active January 3, 2018 15:13
Git commands
#Merge using strategie
git checkout --ours ( --theirs ) filename
#Restart merge
git checkout -m FILE
@celian-m
celian-m / Modern Swift.md
Last active March 22, 2017 07:24
Interesting Swift links