Skip to content

Instantly share code, notes, and snippets.

View phongngtuan's full-sized avatar

Phong Nguyen phongngtuan

View GitHub Profile
#include <iostream>
#include <tgmath.h>
using namespace std;
#define PI 3.14159265
int main()
{
int N;
cin >> N;
Any
AnyVal
ArrayEquals
AsInstanceOf
DefaultArguments
EitherProjectionPartial
Enumeration
Equals
ExplicitImplicitTypes
FinalCaseClass
@phongngtuan
phongngtuan / noob.c
Created September 10, 2017 05:49
Noob
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
char *args[] = {"/usr/bin/ls", NULL};
execvp(args[0], args);
return 0;
}
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#define READ_END 0
#define WRITE_END 1
int tokenize(char *line, char *sep, char *argv[][2000],char **redirect_in, char **redirect_out) {
@phongngtuan
phongngtuan / day-3.scala
Created October 4, 2018 13:06 — forked from calvinlfer/day-3.scala
Functional Scala: Toronto edition
// Copyright(C) 2018 - John A. De Goes. All rights reserved.
package net.degoes.effects
import scalaz.zio._
import scalaz.zio.console._
import scala.annotation.tailrec
import scala.concurrent.duration._
@phongngtuan
phongngtuan / day-1.scala
Created October 4, 2018 13:07 — forked from calvinlfer/day-1.scala
Functional Scala: Toronto edition
// Copyright(C) 2018 - John A. De Goes. All rights reserved.
package net.degoes.essentials
import java.time.{Instant, ZonedDateTime}
import scala.util.Try
object types {
type ??? = Nothing
@phongngtuan
phongngtuan / day-2.scala
Created October 4, 2018 13:07 — forked from calvinlfer/day-2.scala
Functional Scala: Toronto Edition
// Copyright(C) 2018 - John A. De Goes. All rights reserved.
package net.degoes.abstractions
import scalaz._
import Scalaz._
import scala.language.higherKinds
object algebra {
public ListNode reverseList(ListNode head) {
if (head == null) return head;
ListNode curr = head.next;
head.next = null;
while (curr != null) {
ListNode next = curr.next;
curr.next = head;
head = curr;
curr = next;
val doobieVersion = "0.6.0"
import $ivy.`org.tpolecat:doobie-core_2.12:0.6.0`
import $ivy.`org.tpolecat:doobie-postgres_2.12:0.6.0`
import $ivy.`org.tpolecat:doobie-specs2_2.12:0.6.0`
import doobie._
import doobie.implicits._
import cats._
import cats.data._
import cats.effect.IO
import cats.implicits._
import cats._
import cats.implicits._
import cats.effect._
import scala.concurrent.duration._
object ProcessIO {
import scala.sys.process._
def exec[F[_]](commands: String)(implicit F: ConcurrentEffect[F], T: Timer[F]): F[Unit] = {
def acquire: F[Process] = F.delay(commands.run())