vineri, aprilie 10, 2020

Exerciu interesant la matematica la Nicu clasa 2

Sarcina este urmatoare

DOI +DOI +DOI = ȘASE

Unde DOIȘASE sunt cifre diferite si trebuie de gasit aceste cifre care satisfac aceasta egalitate.

Am incercat diferite cifre si nu gaseam, deci am decis sa scriu un programel :)

Scritpul este in javascript scris in editorul de la ramdajs 



const startNumber = 100
const endNumber = 999
const startProductNumber = 1000
const endProductNumber = 9999
const arrayOfNumbers = Array.from(Array(endNumber - startNumber)).map((ai=> startNumber + i)
const isProductInRange = p => p >= startProductNumber && p <= endProductNumber
const isNumberWithUniqNumbers = a => R.uniq(a).length == a.length
const areAnyNumberDuplicates = (kp=> {
  const ks = k.toString(), ps = p.toString()
  return isNumberWithUniqNumbers(ks) && isNumberWithUniqNumbers(ps) && R.intersection(ks,ps).length == 0
}

const reducer = (ack=> {
  const p = k * 3
  if (isProductInRange(p)) {
    if (areAnyNumberDuplicates(kp)) {
      ac = ac.concat(`${k} + ${k} + ${k} = ${p}`)
    }
  }
  return ac
}

const validResults = arrayOfNumbers.reduce(reducer, [])

validResults

Si rezultatul este :)

[
  "354 + 354 + 354 = 1062",
  "358 + 358 + 358 = 1074",
  "364 + 364 + 364 = 1092",
  "534 + 534 + 534 = 1602",
  "543 + 543 + 543 = 1629",
  "568 + 568 + 568 = 1704",
  "582 + 582 + 582 = 1746",
  "583 + 583 + 583 = 1749",
  "594 + 594 + 594 = 1782",
  "609 + 609 + 609 = 1827",
  "634 + 634 + 634 = 1902",
  "658 + 658 + 658 = 1974",
  "673 + 673 + 673 = 2019",
  "678 + 678 + 678 = 2034",
  "681 + 681 + 681 = 2043",
  "683 + 683 + 683 = 2049",
  "691 + 691 + 691 = 2073",
  "768 + 768 + 768 = 2304",
  "819 + 819 + 819 = 2457",
  "839 + 839 + 839 = 2517",
  "873 + 873 + 873 = 2619",
  "891 + 891 + 891 = 2673",
  "906 + 906 + 906 = 2718",
  "916 + 916 + 916 = 2748",
  "918 + 918 + 918 = 2754"
]

joi, august 29, 2019

Search and count specific text in subfolders

Suppose you want to search for lines containing specific text then you want to see the distinct count for all words in all those lines.

1. From git-bash run the following command:

grep -r "word_to_search" ./folder_to_search_in/ | awk -F ":" '{print $2}' > result_file

2. Now run the following command on result_file produces by the command above

cat result_file | tr -s ' ' '\n' | sort | uniq -c | sort -r | awk '{ print $2, $1 }' > outuniq

3. Now file outuniq will contain the uniq words  and count for their occurance

luni, iulie 15, 2019

Permis de conducere Republica Moldova expirat/pierdut/nou lista de documente necesare!

Pentru schimbarea permisului de conducere eliberat de autoritățile Republicii Moldova, este necesar de pregătit următoarele acte:
1. Forma medicală F-027 de la medicul de familie + Persoanele după 40ani tensiunea intraoculară,
2. O poză 3x4   -  este in clădirea din str. Petru Rareș 32 serviciu FOTO, prinzi rând la casă și te întorci ptr poză - prețul pentru 4poze 30 lei,
3. Certificat narcologic (str. Petru Rareș 32)    -  Prețul 59 lei, (orarul: 8.00- 15.30 , pauza de masa 12.00-12.30)
4. Cazier contravențional - (nu Judiciar) str. Iacob Hâncu 3A, nu este posibil de comandat online, 10zile - 30lei, (doar în cazul când se adauga o literă nouă în permisul vechi ori este pierdut)
5. Livret militar sau certificatul de la psihiatru,
6. Ochelarii + reteta pentru ochelari în caz că îi ai,
7. Adeverința medicală a conducătorului de vehicul emisă de IMSP "Dispensarul Municipal Dermatovenerologic" -  Strada Columna 47 - Prețul 133lei  (orarul: 8.00- 17.30, sâmbătă până la 14:00, pauza de masa 13.00-13.30)
8. Copie și Original la Buletin de Identitate,
9. Copie și Original la Permisul Vechi,
10. Copie pe ambele părți și Original la Certificatele Medicale,
11. MRU - SCCA Chișinău - mun. Chișinău, str. Salcîmilor 28 - Ghișeul nr 5
    ori la oricare dintre Centrele Multifuncționale


În cazul permisului expirat sunt necesare doar actele de la punctele 5 până la 11





luni, martie 25, 2019

Get list of children from n-depth tree

const nodes = [
  {
    Children:[{
     Children:[{
      Children:[{
       Children:[],
        NodeId: 'N1111',
        NodeNane: 'Node1111'
      },
      {
        Children:[],
        NodeId: 'N1112',
        NodeNane: 'Node1112'
      }],
       NodeId: 'N111',
       NodeNane: 'Node111'
     },
     {
       Children:[],
       NodeId: 'N112',
       NodeNane: 'Node112'
     }],
     NodeId: 'N11',
     NodeNane: 'Node11'
   },
   {
     Children:[],
     NodeId: 'N12',
     NodeNane: 'Node12'
   }],
    NodeId: 'N1',
    NodeNane: 'Node1'
  },
  {
    Children:[],
    NodeId: 'N2',
    NodeNane: 'Node2'
  },
  {
    Children:[{
        Children:[{
         Children:[{
          Children:[],
          NodeId: 'N3111',
          NodeNane: 'Node3111'
         },
        {
          Children:[],
          NodeId: 'N3112',
          NodeNane: 'Node3112'
        }],
         NodeId: 'N311',
         NodeNane: 'Node311'
        },
        {
         Children:[],
         NodeId: 'N312',
         NodeNane: 'Node312'
       }],
        NodeId: 'N31',
        NodeNane: 'Node31'
      },
      {
        Children:[],
        NodeId: 'N32',
        NodeNane: 'Node32'
      }],
    NodeId: 'N3',
    NodeNane: 'Node2'
  }
]
const getNodes = ar => {
  const node=a=>a.Children.length==0?{NodeId: a.NodeId, NodeName: a.NodeNane}:getNodes(a.Children)
  return [].concat(...ar.map(node))
}

getNodes(nodes)


ramda link

sâmbătă, mai 05, 2018

How to rename files and move them in subdirectory using bash and git


Files rename

The below script will find all files sufixed with "test.js" and will change "test" sufix to "spec"

#!/bin/bash
find . -name "*.test.js" | while read -r FILE; do
FILENEWNAME=${FILE/.test.js/.spec.js}
echo $FILE
#echo $FILENEWNAME
#replace sufix
git mv "$FILE" "$FILENEWNAME"
done


Files Move

The below script will find files sufixed with "spec.js" and will move them to subdirectory "__test__" of the same location, if file is already moved it is ignored

#!/bin/bash
find . -name "*.spec.js" | while read -r FILE; do 
if [[ "$FILE" != *"__tests__"* ]]; then
echo $FILE
DIRNAME=${FILE%/*}
#create subfolder and move file
mkdir -p "$DIRNAME/__tests__" && git mv "$FILE" "$DIRNAME/__tests__/"
fi
done


duminică, aprilie 22, 2018

How to transform JSON Parent, Child to CSV or TSV

Here is the Javascript code:

```javascript
const json ={
  "objects": [{
      "poolname": "Pool One",
      "ip": "10.10.10.10",
      "groups": [{
          "groupname": "Pool 1 Group 1",
          "ip": "100.100.100.100"
      }, {
          "groupname": "Pool 1 Group 2",
          "ip": "150.150.150.150"   
      }]
    },
    {
      "poolname": "Pool Two",
      "ip": "20.20.20.20",
      "groups": [{
          "groupname": "Pool 2 Group 1",
          "ip": "200.200.200.200"
      }, {
          "groupname": "Pool 2 Group 2",
          "ip": "250.250.250.250"   
      }]
    }]
}

const mapOfMap = (separator)=>[].concat(...json.objects.map(o=>o.groups.map(g=>o.poolname+separator+o.ip+separator+g.groupname+separator+g.ip)))
const toLines = l => l.reduce((acc,v)=>acc+v+"\r\n",'')
const csv = toLines(mapOfMap(','))
const tsv = toLines(mapOfMap('\t'))
console.log(csv)
console.log(tsv)
```

also see the ramda share https://goo.gl/EAM36j where you can run the above code

sâmbătă, noiembrie 05, 2016

Notes from Security Awarness lessons

Social Engineering
- Cyber attacks can happen in varietate of ways including emails, instant messages, phone calls
- Tricks to get attention to Cyber attacks: Free download, You Won, Pretending your computer is infected, Emails/Messages pretending to be from your bank.
Email & Messaging
- Fishing attacks come in form of emails/messages pretending to represent your bank
- attacker email may trick you to click on a link, to open an attachment, .. which may infect you computer
- Alerts to a fishing attack may be generic message in the emails not addressing personally to you
- Messages that demand imediat actions
- Spelling mistakes in messages
- Using personal email address such as gmail, yahoo
- Emails asking highly sensitive information such as credit card number, your password
- Before clicking on link hover the link to see the real destination
- Type the address directly in the browser
Browsers attacks:
-Ensure the latest browser update
-Do not open unsafe sites, modern browsers detects bad sites
-Make shure https is used for sites
-Use Only Aproved and latest updates for Plugins or Addons
-Logout from website when finished the actions
-Use
Social Networks
-Strong uniq passwords, different passwords for different accounts, 2 step verifcation to use if posibile
-When posting something ensure it is posted
-When someone you dont know posts something about you ask them to remove or report about it
-Install Social Networks 3rd party application only from trusted sources
-When there is suspicious post from somebody please contact them directly and tell them about
-Do not post confidential information on any sites
Mobile Device Security:
-Protect with screen lock, password, pin,
-Active Remote Wiping
-Apps from trusted sources, read reviews, see popularity
-Check apps permissions required when installing
-Keep apps updated
-Keep Mobile OS updated
-Buy new mobile device if there is no more OS support
-Never jailbreak or hack mobile device
-Be ware of malicious links in sms messages
Passwords
- Do not use simple passwords
- Do not use personal information in passwords like date of birth, name, pet name
- Use long passwords, use Upper/Lower case, Numbers, special chars
- Use Password Managers
- Do not use public computers to log in bank accounts,
- Be aware of sites where personal questions are asked, answers can be found on internet
- Use 2 factor authentication
Data Security and Data Destruction
- It is about how to store, process, transmit and destroy sensitive information
- Use system authorized by organization
- Do not copy organisation information to personal devices
- Use authorized and licensed software
- Do not use cloud services (drop box, iCloud, gDrive) if not approved by org
- Do not leave hard-copy documents on desks, lock them in folders
- Always lock the computer when leaving the desk
- Use strong encryption when sending info over network
- Use aproved external devices and software for storing information
- Use special software to delete secure information
- Always shred hard-copy documents when no longer needed
Working Remotely
- Use only devices provided/approved by organization
- Family members should not use work devices
- Use encrypted channels when connected through public networks like VPNs
- Ensure OS and applications used are up to date.
- Never use public computers for work
- Do not allow others to connect to you devices via usb, bluetooth,...
Insider Threats (created by someone employed )
- Someone asking for information which he/sher is not required to have
- Someone caring large number of documents out of org
- Someone transferring large files when he is not required to do this
- Someone working strange hours
- Someone trying to login in somebody else accounts or asking for access to data centers
- Someone with strange behavior
- Never share you credentials with nobody including your supervisor
Protecting your personal computer
- Your computer is running the latest OS installed and latest application installed ex. Word, Excel, ..
- Automatic updates is activated on you computer/devices
- Uninstall unused application
- Ensure web browsers and thier plugins are updated
- Use private/anonymous mode when browsing on internet
- Ensure Firewall is activate
- Ensure Antivirus is running and is updated
- Perform regular backups of your personal information
Hacked,You may be hacked when:
- Antivirus generates alerts
- Browser takes you to unwanted sites
- Your passwords is no longer working
- Your friends are telling you that they receive messages from facebook, twitter, or email account which you didn't sent.
- Contact security team immediately when you think you was hacked
Payment Card Industry Data Security Standard (PSI DSS)
- Limit data access only to required people
- Do not store sensitive data information
- Store PAN in encrypted form according to org standards
- Verify Identy of the person before granting then access to any payment card device
- Cardholder information should be used only for processing payments
- Only authorized payment system may be used to store, process or transmit cardholder data
Cloud Services
- You never know where data is stored
- Obtain permission to use cloud services in org
- Obtain permission on what type of information can be stored on cloud
- Never access personal cloud accounts from org without prior permission
- Use uniq passwords for your cloud accounts
- Share cloud information only with approved people

joi, octombrie 20, 2016

Cum in Windows verificam spatiul folosit pe disk.

Dese ori ajungem la momentul cind nu mai avem spatiu pe disk, si atunci incepem sa vedem ce sa mai stergem ca sa eliberam din spatiu.

Pentru asta va propun urmatorii pasi:

1. Curatim Recycle Bean-ul
2. Stergem tot din temp folder, deschide  %temp% din Windows->Run si sterge tot din el.
3. Vedem unde se foloseste spatiul si decidem care sa-l eliberam, pentru asta descarcati aplicatia Disk Usage de aici https://technet.microsoft.com/en-us/sysinternals/du.aspx Din command line executati urmatoare comanda: du  -c -l 2 c:/ > 2levelfolderssize.csv

Daca vreti csv sa fie mai detaliat la  nivel de folder atunci puneti in loc de 2 un numar mai mare.

Apoi deschide cu Excel csv fisierul creat.

Membri

Comentarii