Skip to content

Instantly share code, notes, and snippets.

View freakflames29's full-sized avatar
🎯
Focusing

Sourav das freakflames29

🎯
Focusing
View GitHub Profile
@freakflames29
freakflames29 / routes.rb
Created March 22, 2021 16:58
Main routes for user
Rails.application.routes.draw do
# get 'deadpool/home'
# get 'sourav',to: 'deadpool#about'
# get 'deadpool/download'
root 'mains#index'
# registrations routes
get 'signup', to:'registrations#new'
post 'signup', to:'registrations#create'
@freakflames29
freakflames29 / twoway.js
Created March 27, 2021 16:00
Two way data binding in react
const [nameS,setName]=useState({
names:[
{name:'sourav',age:30},
{name:'Toton',age:50},
{name:'Rick grimes',age:10}
],
btn:"Switch all names"
})
// the function which is called when the input value is changed
@freakflames29
freakflames29 / twowayVue.vue
Created March 27, 2021 16:04
two way data binding in vue js
<template>
<h2>Tasks</h2>
<!-- <Check/> -->
<h4>{{msg}}</h4>
<input type="text" v-model="msg">
<!-- <p v-html="html"></p> -->
<!-- <button v-bind:disabled='disbtn'>Thanos</button>111 -->
</template>
<script>
import Check from './Check'
@freakflames29
freakflames29 / app.js
Created March 27, 2021 16:21
Two way data binding in vanilla js
// the html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Two way data binding</title>
</head>
<body>
@freakflames29
freakflames29 / router.js
Created March 30, 2021 15:56
Routes in react
//npm install react-router-dom
// run this after creating a react project
/***************************************** App.js *******************************************/
import "./App.css";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Compo from './Thec'
import About from './About'
function App() {
@freakflames29
freakflames29 / ruby.rb
Created April 3, 2021 15:05
passing symbols as an argument to a function which calls the same name function as the symbol name
def set_name
puts "Your name is good"
end
def before_action (func)
method(func).call
end
before_action :set_name
# it is a normal ruby code which takes symbols and call the same name function as symbol
@freakflames29
freakflames29 / regex.rb
Created April 9, 2021 12:41
Valid email regex
VALID_EMAIL_REGEX= /^(|(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6})$/i
validates :email , presence: true,uniqueness:{case_sensetive:false},
format:{with:VALID_EMAIL_REGEX,multiline:true}
@freakflames29
freakflames29 / equal_or.rb
Created April 14, 2021 06:24
Ruby equal or operator
x ||= {}
x[:key]="lock"
x[:key]||=50
puts x
# output {:key=>"lock"}
#it is used to assign a value to variable if the variable is not assigned and afer assigning the value we can't change it to new value
@freakflames29
freakflames29 / struct.cpp
Created April 21, 2021 16:12
nested structure in c++
#include<iostream>
using namespace std;
struct Read
{
string areyou;
struct Book
{
string name;
struct Price
{
@freakflames29
freakflames29 / merge.py
Created May 5, 2021 06:51
merge sort in python
def ms(n):
if len(n)>1:
mid=len(n)//2
lefthalf=n[:mid]
righthalf=n[mid:]
ms(lefthalf)
ms(righthalf)
i=j=k=0
while i<len(lefthalf) and j<len(righthalf):
if lefthalf[i]<righthalf[j]: